Table of Contents

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

serviceFactory IMasterListServiceFactory
logger ILogger<MasterListController>
listSettings IOptions<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

typeName string

The name of the master list type used to resolve the appropriate service.

id string

The string representation of the master list identifier.

opt FilterOptionListElement

The 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 typeName cannot be parsed into a valid MasterListType value.

BadRequestException

Thrown when id is not a valid ObjectId format.

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

typeName string

The name of the master list type used to resolve the appropriate service.

id string

The string representation of the master list item's ObjectId to delete.

Returns

Task<IActionResult>

An IActionResult that returns Ok when the master list item is successfully deleted.

Exceptions

BadRequestException

Thrown when typeName cannot be parsed as a MasterListType value.

BadRequestException

Thrown when id is 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

typeName string

The name of the master list type, used to resolve the appropriate service and parse to MasterListType.

id string

The ObjectId of the master list containing the option to delete.

itemId string

The ObjectId of the master list option to remove.

Returns

Task<IActionResult>

An IActionResult containing the result of the deletion operation.

Exceptions

BadRequestException

Thrown when typeName does not match a known master list type.

BadRequestException

Thrown when id or itemId are 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

typeName string

The 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 typeName does not correspond to a valid MasterListType value.

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

typeName string

The name of the master list type used to resolve the corresponding service.

id string

The unique identifier of the master list entry to retrieve.

Returns

Task<IActionResult>

An IActionResult containing the requested master list entry.

Exceptions

BadRequestException

Thrown when typeName cannot be parsed as a valid MasterListType.

BadRequestException

Thrown when id is not in a valid ObjectId format.

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

typeName string

Tipo de Lista

id string

id de la lista

searchOptions FilterOptionListElement

Returns

Task<IActionResult>

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

typeName string

The name of the master list type used to resolve the corresponding service.

id string

The string representation of the master list identifier, which must be a valid ObjectId.

request PaginationFilter

The 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 typeName does not correspond to a valid MasterListType value.

BadRequestException

Thrown when id is 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

typeName string

The string representation of the MasterListType used to resolve the backing service.

name string

The 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 typeName cannot 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

typeName string

The name of the master list type used to resolve the corresponding service via the service factory.

textSearch string

The 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 typeName cannot be parsed to a valid MasterListType value.

BadRequestException

Thrown when textSearch is 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

typeName string

The 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 typeName cannot 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

typeName string

The name of the master list type used to resolve the appropriate service.

id string

The 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 typeName cannot be parsed as a MasterListType value.

BadRequestException

Thrown when id is 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

typeName string

The name of the master list type to query, matched against the MasterListType enumeration.

request PaginationFilter

The 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 typeName cannot 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

typeName string

The name of the source MasterListType used to resolve the originating service.

listId string

The identifier of the source master list from which the related list is resolved.

targetCategory string

The 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 typeName or targetCategory cannot be parsed as a valid MasterListType, or when listId is 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

request PaginationFilter

The pagination filter containing paging criteria applied to the master list query.

typeName string

The 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 typeName cannot 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

filters PaginationPairDto

The pagination pair DTO containing the list filter and option filter used to narrow the results.

typeName string

The 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 typeName cannot be parsed as a valid MasterListType.

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

typeName string

The name of the master list type to resolve from MasterListType.

id string

The identifier of the master list used to scope the paginated options.

request PaginationFilter

The pagination filter applied to the requested options.

Returns

Task<IActionResult>

An IActionResult containing the paginated options payload.

Exceptions

BadRequestException

Thrown when typeName cannot be parsed as a valid MasterListType value.

BadRequestException

Thrown when id is 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

typeName string

The name of the master list type used to resolve the target MasterListType.

master MasterList

The master list payload received from the request body.

Returns

Task<IActionResult>

An IActionResult containing the result of the insert operation.

Exceptions

BadRequestException

Thrown when master is null.

BadRequestException

Thrown when typeName cannot 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

typeName string

The name of the master list type; must correspond to a value of MasterListType.

id string

The identifier of the master list entry; must be a valid MongoDB.Bson.ObjectId.

master MasterList

The 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 master is null; when typeName cannot be parsed into a MasterListType; or when id is 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

typeName string

The name of the master list type used to resolve the appropriate service.

id string

The identifier of the master list entry to update.

udpateListNameAndDescriptionDto UpdateListNameAndDescriptionDto

The 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 typeName does not correspond to a valid master list type.

BadRequestException

Thrown when id is 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

typeName string

The name of the master list type to update; must map to a MasterListType value.

id string

The identifier of the master list to rename; must be a valid ObjectId.

udpateListNameAndDescriptionDto UpdateListNameAndDescriptionDto

The 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 typeName does not correspond to a known master list type, or when id is 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

typeName string

The name of the master list type to update; must parse to a valid MasterListType.

id string

The identifier of the master list entry to update; must be a valid ObjectId format.

opt UpdateMasterListDetailsDto

The 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 typeName does not correspond to a valid master list type, or when id is 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

locale string

The locale identifier used to resolve the target language context.

typeName string

The name of the master list type whose option should be updated.

id string

The identifier of the master list entry to update.

opt OptionList

The 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 typeName is not a valid MasterListType, when locale is not a valid LocaleEnum, or when id is 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

typeName string

The name of the master list type used to resolve the target service and operation.

id string

The unique identifier of the master list entry to update.

opt OptionList

The 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 Conflict response when the update fails.

Exceptions

BadRequestException

Thrown when typeName does not match a valid MasterListType value.

BadRequestException

Thrown when id is not a valid MongoDB.Bson.ObjectId format.