Class MasterListController
- Namespace
- adas_core.Controllers
- Assembly
- adas-core.dll
[Route("master-lists")]
[ApiController]
public class MasterListController : ControllerBase
- Inheritance
-
MasterListController
- Inherited Members
- Extension Methods
Constructors
MasterListController(IMasterListServiceFactory, ILogger<MasterListController>, IOptions<ListSettings>)
public MasterListController(IMasterListServiceFactory serviceFactory, ILogger<MasterListController> logger, IOptions<ListSettings> listSettings)
Parameters
serviceFactoryIMasterListServiceFactoryloggerILogger<MasterListController>listSettingsIOptions<ListSettings>
Methods
AddOptionToMasterList(string, string, FilterOptionListElement)
Adds a filter option to a master list identified by its type name and id. Validates that the type name maps to a known master list type and that the id has a valid format before delegating the operation to the service resolved through the service factory.
[HttpPost("{typeName}/{id}/item")]
[AuthorizeRoles(PermissionEnum.RolesType.AuthSome)]
[PermissionAuthorize("Source", "DisplayId")]
public Task<IActionResult> AddOptionToMasterList(string typeName, string id, FilterOptionListElement opt)
Parameters
typeNamestringThe name of the master list type used to resolve the appropriate service.
idstringThe string representation of the master list identifier.
optFilterOptionListElementThe filter option element to add to the master list, supplied in the request body.
Returns
- Task<IActionResult>
An IActionResult containing the result of the add operation.
Exceptions
- BadRequestException
Thrown when
typeNamecannot be parsed into a validMasterListTypevalue.- BadRequestException
Thrown when
idis not a validObjectIdformat.
DeleteMasterList(string, string)
Deletes a master list item identified by its type name and identifier. Validates that the supplied type name maps to a known MasterListType and that the identifier is a valid ObjectId before delegating the deletion to the corresponding service.
[HttpDelete("{typeName}/{id}")]
[AuthorizeRoles(PermissionEnum.RolesType.AuthSome)]
[PermissionAuthorize("Source", "DisplayId")]
public Task<IActionResult> DeleteMasterList(string typeName, string id)
Parameters
typeNamestringThe name of the master list type used to resolve the appropriate service.
idstringThe string representation of the master list item's ObjectId to delete.
Returns
- Task<IActionResult>
An IActionResult that returns
Okwhen the master list item is successfully deleted.
Exceptions
- BadRequestException
Thrown when
typeNamecannot be parsed as a MasterListType value.- BadRequestException
Thrown when
idis not a valid ObjectId format.
DeleteOptionFromMasterList(string, string, string)
Deletes a specific option from a master list, identified by its type, master list ID, and item ID. Validates that the type is a known master list type and that both the master list and item identifiers are valid ObjectId values. If the deletion produces no result, a conflict exception is thrown.
[HttpDelete("{typeName}/{id}/item/{itemId}")]
[AuthorizeRoles(PermissionEnum.RolesType.AuthSome)]
[PermissionAuthorize("Source", "DisplayId")]
public Task<IActionResult> DeleteOptionFromMasterList(string typeName, string id, string itemId)
Parameters
typeNamestringThe name of the master list type, used to resolve the appropriate service and parse to MasterListType.
idstringThe ObjectId of the master list containing the option to delete.
itemIdstringThe ObjectId of the master list option to remove.
Returns
- Task<IActionResult>
An IActionResult containing the result of the deletion operation.
Exceptions
- BadRequestException
Thrown when
typeNamedoes not match a known master list type.- BadRequestException
Thrown when
idoritemIdare not valid ObjectId values.- ConflictException
Thrown when the deletion operation returns no result.
GetAllMasterListCounts()
Retrieves the record count for every MasterListType by resolving the corresponding service through the service factory and aggregating the results into a single dictionary. Requires the "AuthSome" role and the "DisplayId" permission on the "Source" resource.
[HttpGet("count")]
[AuthorizeRoles(PermissionEnum.RolesType.AuthSome)]
[PermissionAuthorize("Source", "DisplayId")]
public Task<IActionResult> GetAllMasterListCounts()
Returns
- Task<IActionResult>
An IActionResult containing a Dictionary<TKey, TValue> that maps each MasterListType to its total record count, returned with HTTP 200 OK.
GetAllMasterListWithoutOptions()
Retrieves all master list entries (without their associated options) for every MasterListType value, aggregating the results from each type's dedicated service resolved through the service factory.
[HttpGet("no-options")]
[AuthorizeRoles(PermissionEnum.RolesType.AuthSome)]
[PermissionAuthorize("Source", "DisplayId")]
public Task<IActionResult> GetAllMasterListWithoutOptions()
Returns
- Task<IActionResult>
An IActionResult containing an HTTP 200 response with the combined collection of MasterListDto items gathered from all master list services.
GetMasterList(string)
Retrieves a master list for the specified type by resolving the appropriate service through the service factory and returning its full collection of records.
[HttpGet("{typeName}")]
[AuthorizeRoles(PermissionEnum.RolesType.AuthSome)]
[PermissionAuthorize("Source", "DisplayId")]
public Task<IActionResult> GetMasterList(string typeName)
Parameters
typeNamestringThe name of the master list type used to resolve the corresponding service.
Returns
- Task<IActionResult>
An IActionResult containing the master list data when the specified type is valid.
Exceptions
- BadRequestException
Thrown when
typeNamedoes not correspond to a validMasterListTypevalue.
GetMasterListById(string, string)
Retrieves a master list entry of the specified type by its unique identifier, delegating the lookup to the appropriate service resolved by the master list type.
[HttpGet("{typeName}/{id}")]
[AuthorizeRoles(PermissionEnum.RolesType.AuthSome)]
[PermissionAuthorize("Source", "DisplayId")]
public Task<IActionResult> GetMasterListById(string typeName, string id)
Parameters
typeNamestringThe name of the master list type used to resolve the corresponding service.
idstringThe unique identifier of the master list entry to retrieve.
Returns
- Task<IActionResult>
An IActionResult containing the requested master list entry.
Exceptions
- BadRequestException
Thrown when
typeNamecannot be parsed as a validMasterListType.- BadRequestException
Thrown when
idis not in a validObjectIdformat.
GetMasterListByIdAndSearchOptions(string, string, FilterOptionListElement)
Busca las opciones que contengan un texto de una lista determinada
[HttpPost("{typeName}/{id}/options")]
[AuthorizeRoles(PermissionEnum.RolesType.AuthSome)]
[PermissionAuthorize("Source", "DisplayId")]
public Task<IActionResult> GetMasterListByIdAndSearchOptions(string typeName, string id, FilterOptionListElement searchOptions)
Parameters
typeNamestringTipo de Lista
idstringid de la lista
searchOptionsFilterOptionListElement
Returns
GetMasterListByIdWithPaginatedOptions(string, string, PaginationFilter)
Retrieves paginated options for a master list entry by its type and identifier. Validates the type name against the supported MasterListType values and ensures the identifier is a valid ObjectId, delegating the actual retrieval to the appropriate service resolved through the service factory.
[HttpPost("{typeName}/{id}/master-list-paginated-options")]
[AuthorizeRoles(PermissionEnum.RolesType.AuthSome)]
[PermissionAuthorize("Source", "DisplayId")]
public Task<IActionResult> GetMasterListByIdWithPaginatedOptions(string typeName, string id, PaginationFilter request)
Parameters
typeNamestringThe name of the master list type used to resolve the corresponding service.
idstringThe string representation of the master list identifier, which must be a valid ObjectId.
requestPaginationFilterThe pagination filter applied to the master list options query.
Returns
- Task<IActionResult>
An IActionResult containing the paginated master list options returned by the resolved service.
Exceptions
- BadRequestException
Thrown when
typeNamedoes not correspond to a valid MasterListType value.- BadRequestException
Thrown when
idis not a valid ObjectId format.
GetMasterListByName(string, string)
Retrieves a master list entry by its name, resolving the appropriate service based on the provided type. Validates that the type name maps to a known MasterListType; otherwise returns a bad request.
[HttpGet("{typeName}/{name}/name")]
[AuthorizeRoles(PermissionEnum.RolesType.AuthSome)]
[PermissionAuthorize("Source", "DisplayId")]
public Task<IActionResult> GetMasterListByName(string typeName, string name)
Parameters
typeNamestringThe string representation of the MasterListType used to resolve the backing service.
namestringThe name of the master list entry to look up.
Returns
- Task<IActionResult>
An IActionResult containing the result of the master list lookup.
Exceptions
- BadRequestException
Thrown when
typeNamecannot be parsed into a valid MasterListType.
GetMasterListByTextSearch(string, string?)
Retrieves a master list filtered by a text search term, selecting the appropriate service implementation based on the specified master list type. Validates that the type name corresponds to a known MasterListType and that the search text meets the minimum length requirement.
[HttpGet("{typeName}/{textSearch}/text")]
[AuthorizeRoles(PermissionEnum.RolesType.AuthSome)]
[PermissionAuthorize("Source", "DisplayId")]
public Task<IActionResult> GetMasterListByTextSearch(string typeName, string? textSearch)
Parameters
typeNamestringThe name of the master list type used to resolve the corresponding service via the service factory.
textSearchstringThe text used to filter the master list entries. Must be at least 3 characters long.
Returns
- Task<IActionResult>
An IActionResult containing the filtered master list results returned by the resolved service.
Exceptions
- BadRequestException
Thrown when
typeNamecannot be parsed to a valid MasterListType value.- BadRequestException
Thrown when
textSearchis provided but is shorter than 3 characters.
GetMasterListCount(string)
Retrieves the total count of master list items for a specified master list type.
[HttpGet("{typeName}/count")]
[AuthorizeRoles(PermissionEnum.RolesType.AuthSome)]
[PermissionAuthorize("Source", "DisplayId")]
public Task<IActionResult> GetMasterListCount(string typeName)
Parameters
typeNamestringThe name of the master list type to count, parsed into the MasterListType enum.
Returns
- Task<IActionResult>
An IActionResult containing the count of master list items.
Exceptions
- BadRequestException
Thrown when the provided
typeNamecannot be parsed into a valid MasterListType.
GetMasterListOptionsNamesById(string, string)
Retrieves the master list options names for a specific master list entry, identified by its type and ID. Validates that the provided type name corresponds to a known MasterListType and that the ID is a valid MongoDB.Bson.ObjectId, delegating the lookup to the service resolved for the matching master list type.
[HttpGet("{typeName}/{id}/master-list-options-names")]
[AuthorizeRoles(PermissionEnum.RolesType.AuthSome)]
[PermissionAuthorize("Source", "DisplayId")]
public Task<IActionResult> GetMasterListOptionsNamesById(string typeName, string id)
Parameters
typeNamestringThe name of the master list type used to resolve the appropriate service.
idstringThe identifier of the master list entry whose options names should be retrieved.
Returns
- Task<IActionResult>
An IActionResult containing the master list options names returned by the resolved service.
Exceptions
- BadRequestException
Thrown when
typeNamecannot be parsed as a MasterListType value.- BadRequestException
Thrown when
idis not a valid MongoDB.Bson.ObjectId format.
GetMasterListSettings()
Retrieves the master list settings for the authenticated user with the required permission.
[HttpGet("list-settings")]
[AuthorizeRoles(PermissionEnum.RolesType.AuthSome)]
public IActionResult GetMasterListSettings()
Returns
- IActionResult
An IActionResult containing the master list settings on success.
GetMasterListWithPaginatedOptions(string, PaginationFilter)
Retrieves a paginated master list of items for the specified master list type.
Validates the typeName against the MasterListType enumeration
and resolves the appropriate service via the service factory to fetch the results.
[HttpPost("{typeName}/paginated-options")]
[AuthorizeRoles(PermissionEnum.RolesType.AuthSome)]
[PermissionAuthorize("Source", "DisplayId")]
public Task<IActionResult> GetMasterListWithPaginatedOptions(string typeName, PaginationFilter request)
Parameters
typeNamestringThe name of the master list type to query, matched against the MasterListType enumeration.
requestPaginationFilterThe pagination filter containing paging criteria applied to the master list query.
Returns
- Task<IActionResult>
An IActionResult containing the paginated master list result wrapped in an HTTP 200 OK response.
Exceptions
- BadRequestException
Thrown when
typeNamecannot be parsed into a valid MasterListType value.
GetOptionTypeList(string, string, string)
Retrieves the related options master list associated with a given source list. Validates that the provided type names map to valid MasterListType values and that the list identifier is a valid ObjectId; resolves the related list id through the source list service and returns the corresponding master list for the default locale.
[HttpGet("{typeName}/{listId}/related-options/{targetCategory}")]
[AuthorizeRoles(PermissionEnum.RolesType.AuthSome)]
[PermissionAuthorize("Source", "DisplayId")]
public Task<IActionResult> GetOptionTypeList(string typeName, string listId, string targetCategory)
Parameters
typeNamestringThe name of the source MasterListType used to resolve the originating service.
listIdstringThe identifier of the source master list from which the related list is resolved.
targetCategorystringThe name of the target MasterListType used to resolve the related options service.
Returns
- Task<IActionResult>
The MasterList containing the related options for the requested category.
Exceptions
- BadRequestException
Thrown when
typeNameortargetCategorycannot be parsed as a valid MasterListType, or whenlistIdis not a valid ObjectId.
GetPaginatedMasterList(PaginationFilter, string)
Retrieves a paginated master list of the specified type. Validates the typeName against the MasterListType enumeration and dispatches the request to the corresponding service resolved through the service factory.
[HttpPost("{typeName}/paginated")]
[AuthorizeRoles(PermissionEnum.RolesType.AuthSome)]
[PermissionAuthorize("Source", "DisplayId")]
public Task<IActionResult> GetPaginatedMasterList(PaginationFilter request, string typeName)
Parameters
requestPaginationFilterThe pagination filter containing paging criteria applied to the master list query.
typeNamestringThe string identifier of the master list type, which is parsed into the MasterListType enum to resolve the appropriate service.
Returns
- Task<IActionResult>
An IActionResult containing the paginated master list result.
Exceptions
- BadRequestException
Thrown when
typeNamecannot be parsed into a valid MasterListType value.
GetPaginatedMasterListWithPaginatedOptions(PaginationPairDto, string)
Retrieves a paginated master list along with its associated paginated options for the specified master list type, applying both list and option filters.
[HttpPost("{typeName}/paginated-master-list-paginated-options")]
[AuthorizeRoles(PermissionEnum.RolesType.AuthSome)]
[PermissionAuthorize("Source", "DisplayId")]
public Task<IActionResult> GetPaginatedMasterListWithPaginatedOptions(PaginationPairDto filters, string typeName)
Parameters
filtersPaginationPairDtoThe pagination pair DTO containing the list filter and option filter used to narrow the results.
typeNamestringThe name of the master list type used to resolve the corresponding service through the service factory.
Returns
- Task<IActionResult>
An IActionResult containing the paginated master list result with its options.
Exceptions
- BadRequestException
Thrown when the provided
typeNamecannot be parsed as a validMasterListType.
GetPaginatedOptions(string, string, PaginationFilter)
Retrieves paginated options for a specified master list type and identifier, supporting role-based access and permission authorization.
[HttpPost("{typeName}/{id}/paginated-options")]
[AuthorizeRoles(PermissionEnum.RolesType.AuthSome)]
[PermissionAuthorize("Source", "DisplayId")]
public Task<IActionResult> GetPaginatedOptions(string typeName, string id, PaginationFilter request)
Parameters
typeNamestringThe name of the master list type to resolve from MasterListType.
idstringThe identifier of the master list used to scope the paginated options.
requestPaginationFilterThe pagination filter applied to the requested options.
Returns
- Task<IActionResult>
An IActionResult containing the paginated options payload.
Exceptions
- BadRequestException
Thrown when
typeNamecannot be parsed as a valid MasterListType value.- BadRequestException
Thrown when
idis not a valid MongoDB.Bson.ObjectId format.
InsertMasterListFromPanel(string, MasterList)
Inserts a master list from the panel based on the specified master list type. Validates that the request body is provided and that the type name corresponds to a valid MasterListType.
[HttpPost("{typeName}")]
[AuthorizeRoles(PermissionEnum.RolesType.AuthSome)]
[PermissionAuthorize("Source", "DisplayId")]
public Task<IActionResult> InsertMasterListFromPanel(string typeName, MasterList master)
Parameters
typeNamestringThe name of the master list type used to resolve the target MasterListType.
masterMasterListThe master list payload received from the request body.
Returns
- Task<IActionResult>
An IActionResult containing the result of the insert operation.
Exceptions
- BadRequestException
Thrown when
masteris null.- BadRequestException
Thrown when
typeNamecannot be parsed into a valid MasterListType.
UpdateMasterList(string, string, MasterList)
Updates an existing master list entry identified by its type and identifier, replacing its contents with the supplied payload.
[HttpPut("{typeName}/{id}")]
[AuthorizeRoles(PermissionEnum.RolesType.AuthSome)]
[PermissionAuthorize("Source", "DisplayId")]
public Task<IActionResult> UpdateMasterList(string typeName, string id, MasterList master)
Parameters
typeNamestringThe name of the master list type; must correspond to a value of MasterListType.
idstringThe identifier of the master list entry; must be a valid MongoDB.Bson.ObjectId.
masterMasterListThe master list payload containing the new values to persist.
Returns
- Task<IActionResult>
An IActionResult containing the result of the update operation.
Exceptions
- BadRequestException
Thrown when
masteris null; whentypeNamecannot be parsed into a MasterListType; or whenidis not a valid MongoDB.Bson.ObjectId.
UpdateMasterListDescription(string, string, UpdateListNameAndDescriptionDto)
Updates the description of a master list entry identified by its type and id. Validates that the type name maps to a known master list type, the id is a valid identifier, and the description is not null, then delegates the update to the appropriate service; returns a conflict response if the update fails.
[HttpPut("{typeName}/{id}/description")]
[AuthorizeRoles(PermissionEnum.RolesType.AuthSome)]
[PermissionAuthorize("Source", "DisplayId")]
public Task<IActionResult> UpdateMasterListDescription(string typeName, string id, UpdateListNameAndDescriptionDto udpateListNameAndDescriptionDto)
Parameters
typeNamestringThe name of the master list type used to resolve the appropriate service.
idstringThe identifier of the master list entry to update.
udpateListNameAndDescriptionDtoUpdateListNameAndDescriptionDtoThe DTO containing the new description to apply to the master list entry.
Returns
- Task<IActionResult>
An IActionResult that returns OK on success, BadRequest when the description is null, or Conflict when the update does not succeed.
Exceptions
- BadRequestException
Thrown when
typeNamedoes not correspond to a valid master list type.- BadRequestException
Thrown when
idis not in a valid identifier format.
UpdateMasterListName(string, string, UpdateListNameAndDescriptionDto)
Updates the name of a master list of the specified type and identifier, enforcing role-based and "Source"/"DisplayId" permissions. Validates the master list type, the object id format, and the presence of a new name; returns 409 Conflict when the underlying update fails.
[HttpPut("{typeName}/{id}/name")]
[AuthorizeRoles(PermissionEnum.RolesType.AuthSome)]
[PermissionAuthorize("Source", "DisplayId")]
public Task<IActionResult> UpdateMasterListName(string typeName, string id, UpdateListNameAndDescriptionDto udpateListNameAndDescriptionDto)
Parameters
typeNamestringThe name of the master list type to update; must map to a MasterListType value.
idstringThe identifier of the master list to rename; must be a valid ObjectId.
udpateListNameAndDescriptionDtoUpdateListNameAndDescriptionDtoThe payload containing the new name to apply to the master list.
Returns
- Task<IActionResult>
An IActionResult with the result of the update, BadRequestResult when the name is missing, or ConflictObjectResult when the update fails.
Exceptions
- BadRequestException
Thrown when
typeNamedoes not correspond to a known master list type, or whenidis not a valid ObjectId.
UpdateOptionDetailsFromMasterList(string, string, UpdateMasterListDetailsDto)
Updates the details of a master list option of the specified type, after validating the type and identifier. Returns a conflict response if the service cannot update the details, otherwise returns the updated result.
[HttpPut("{typeName}/{id}/details")]
[AuthorizeRoles(PermissionEnum.RolesType.AuthSome)]
[PermissionAuthorize("Source", "DisplayId")]
public Task<IActionResult> UpdateOptionDetailsFromMasterList(string typeName, string id, UpdateMasterListDetailsDto opt)
Parameters
typeNamestringThe name of the master list type to update; must parse to a valid MasterListType.
idstringThe identifier of the master list entry to update; must be a valid ObjectId format.
optUpdateMasterListDetailsDtoThe payload containing the new details to apply to the master list entry.
Returns
- Task<IActionResult>
The updated master list result wrapped in an IActionResult, or a conflict response when the update fails.
Exceptions
- BadRequestException
Thrown when
typeNamedoes not correspond to a valid master list type, or whenidis not a valid ObjectId.
UpdateOptionFromMasterList(string, string, string, OptionList)
Updates an option within the specified master list, supporting multiple master list types and locales.
[HttpPut("{locale}/{typeName}/{id}/item")]
[AuthorizeRoles(PermissionEnum.RolesType.AuthSome)]
[PermissionAuthorize("Source", "DisplayId")]
public Task<IActionResult> UpdateOptionFromMasterList(string locale, string typeName, string id, OptionList opt)
Parameters
localestringThe locale identifier used to resolve the target language context.
typeNamestringThe name of the master list type whose option should be updated.
idstringThe identifier of the master list entry to update.
optOptionListThe option payload containing the updated values.
Returns
- Task<IActionResult>
The updated master list result on success; otherwise, a 409 Conflict when the update fails.
Exceptions
- BadRequestException
Thrown when
typeNameis not a valid MasterListType, whenlocaleis not a valid LocaleEnum, or whenidis not a valid ObjectId.
UpdateOptionMasterListFromAdmPanel(string, string, OptionList)
Updates an option within a master list identified by its type and identifier from the administrative panel.
[HttpPut("{typeName}/{id}/item")]
[AuthorizeRoles(PermissionEnum.RolesType.AuthSome)]
[PermissionAuthorize("Source", "DisplayId")]
public Task<IActionResult> UpdateOptionMasterListFromAdmPanel(string typeName, string id, OptionList opt)
Parameters
typeNamestringThe name of the master list type used to resolve the target service and operation.
idstringThe unique identifier of the master list entry to update.
optOptionListThe option payload containing the values to apply to the master list entry.
Returns
- Task<IActionResult>
An IActionResult that returns the updated result on success or a
Conflictresponse when the update fails.
Exceptions
- BadRequestException
Thrown when
typeNamedoes not match a valid MasterListType value.- BadRequestException
Thrown when
idis not a valid MongoDB.Bson.ObjectId format.