Class CompanyTypesController
- Namespace
- KadicErp.WebApi.Controllers.ReferenceData
- Assembly
- KadicErp.WebApi.dll
[Route("api/[controller]")]
[Authorize]
public class CompanyTypesController : GenericCrudControllerBase<CompanyTypeDto, CreateCompanyTypeCommand, UpdateCompanyTypeCommand, GetCompanyTypeByIdQuery, GetAllCompanyTypesQuery>
- Inheritance
-
objectControllerBaseGenericCrudControllerBase<CompanyTypeDto, CreateCompanyTypeCommand, UpdateCompanyTypeCommand, GetCompanyTypeByIdQuery, GetAllCompanyTypesQuery>CompanyTypesController
- Inherited Members
-
GenericCrudControllerBase<CompanyTypeDto, CreateCompanyTypeCommand, UpdateCompanyTypeCommand, GetCompanyTypeByIdQuery, GetAllCompanyTypesQuery>.SenderGenericCrudControllerBase<CompanyTypeDto, CreateCompanyTypeCommand, UpdateCompanyTypeCommand, GetCompanyTypeByIdQuery, GetAllCompanyTypesQuery>.CreateGetByIdQuery(Guid)GenericCrudControllerBase<CompanyTypeDto, CreateCompanyTypeCommand, UpdateCompanyTypeCommand, GetCompanyTypeByIdQuery, GetAllCompanyTypesQuery>.CreateGetAllQuery(PaginatorRequestDto, bool?)GenericCrudControllerBase<CompanyTypeDto, CreateCompanyTypeCommand, UpdateCompanyTypeCommand, GetCompanyTypeByIdQuery, GetAllCompanyTypesQuery>.SetCommandId(UpdateCompanyTypeCommand, Guid)GenericCrudControllerBase<CompanyTypeDto, CreateCompanyTypeCommand, UpdateCompanyTypeCommand, GetCompanyTypeByIdQuery, GetAllCompanyTypesQuery>.HandleCommandResult(Result)GenericCrudControllerBase<CompanyTypeDto, CreateCompanyTypeCommand, UpdateCompanyTypeCommand, GetCompanyTypeByIdQuery, GetAllCompanyTypesQuery>.HandleCommandResult<T>(Result<T>, string)GenericCrudControllerBase<CompanyTypeDto, CreateCompanyTypeCommand, UpdateCompanyTypeCommand, GetCompanyTypeByIdQuery, GetAllCompanyTypesQuery>.Create(CreateCompanyTypeCommand)GenericCrudControllerBase<CompanyTypeDto, CreateCompanyTypeCommand, UpdateCompanyTypeCommand, GetCompanyTypeByIdQuery, GetAllCompanyTypesQuery>.Update(Guid, UpdateCompanyTypeCommand)GenericCrudControllerBase<CompanyTypeDto, CreateCompanyTypeCommand, UpdateCompanyTypeCommand, GetCompanyTypeByIdQuery, GetAllCompanyTypesQuery>.GetById(Guid)GenericCrudControllerBase<CompanyTypeDto, CreateCompanyTypeCommand, UpdateCompanyTypeCommand, GetCompanyTypeByIdQuery, GetAllCompanyTypesQuery>.GetAll(PaginatorRequestDto, bool?)
Constructors
CompanyTypesController(ISender, IStringLocalizer<GeneralMessages>)
public CompanyTypesController(ISender sender, IStringLocalizer<GeneralMessages> localizer)
Parameters
senderISenderlocalizerIStringLocalizer<GeneralMessages>
Methods
Activate(Guid)
[HttpPatch("{id}/activate")]
[Authorize(Policy = "REFERENCE_DATA_COMPANY_TYPES_ACTIVATE")]
public Task<IActionResult> Activate(Guid id)
Parameters
idGuid
Returns
- Task<IActionResult>
Create(CreateCompanyTypeCommand)
POST endpoint for creating a new entity. Returns 201 Created with Location header on success.
IMPORTANT: Override in derived class to add [HttpPost] and [Authorize(Policy = ...)]
[HttpPost]
[Authorize(Policy = "REFERENCE_DATA_COMPANY_TYPES_CREATE")]
[ProducesResponseType(typeof(Result<Guid>), 201)]
[ProducesResponseType(typeof(Result), 400)]
[ProducesResponseType(typeof(Result), 409)]
public override Task<IActionResult> Create(CreateCompanyTypeCommand command)
Parameters
commandCreateCompanyTypeCommand
Returns
- Task<IActionResult>
Deactivate(Guid)
[HttpPatch("{id}/deactivate")]
[Authorize(Policy = "REFERENCE_DATA_COMPANY_TYPES_DEACTIVATE")]
public Task<IActionResult> Deactivate(Guid id)
Parameters
idGuid
Returns
- Task<IActionResult>
GetAll(PaginatorRequestDto, bool?)
GET endpoint for retrieving paginated list of entities. Supports optional isActive filter.
IMPORTANT: Override in derived class to add [HttpGet] and [Authorize(Policy = ...)] Override CreateGetAllQuery if you need additional filters. Note: ProducesResponseType attributes cannot be added here due to generic type parameters. Add them in derived class if needed for Swagger documentation.
[HttpGet]
[Authorize(Policy = "REFERENCE_DATA_COMPANY_TYPES_VIEW")]
[ProducesResponseType(typeof(PaginatorResponseDto<CompanyTypeDto>), 200)]
[ProducesResponseType(typeof(Error), 400)]
public override Task<IActionResult> GetAll(PaginatorRequestDto paginator, bool? isActive = null)
Parameters
paginatorPaginatorRequestDtoisActivebool?
Returns
- Task<IActionResult>
GetById(Guid)
GET endpoint for retrieving a single entity by ID. Returns 404 Not Found if entity doesn't exist.
IMPORTANT: Override in derived class to add [HttpGet("{id}")] and [Authorize(Policy = ...)] Note: ProducesResponseType attributes cannot be added here due to generic type parameters. Add them in derived class if needed for Swagger documentation.
[HttpGet("{id}")]
[Authorize(Policy = "REFERENCE_DATA_COMPANY_TYPES_VIEW")]
[ProducesResponseType(typeof(CompanyTypeDto), 200)]
[ProducesResponseType(typeof(Error), 404)]
public override Task<IActionResult> GetById(Guid id)
Parameters
idGuid
Returns
- Task<IActionResult>
SetCommandId(UpdateCompanyTypeCommand, Guid)
Updates the command with the ID from route. This method must be overridden in derived classes to properly set the Id.
For record types with 'with' expression, use:
protected override UpdateXCommand SetCommandId(UpdateXCommand command, Guid id)
=> command with { Id = id };
protected override UpdateCompanyTypeCommand SetCommandId(UpdateCompanyTypeCommand command, Guid id)
Parameters
commandUpdateCompanyTypeCommandidGuid
Returns
- UpdateCompanyTypeCommand
Update(Guid, UpdateCompanyTypeCommand)
PUT endpoint for updating an existing entity. Returns 200 OK on success.
IMPORTANT: Override in derived class to add [HttpPut("{id}")] and [Authorize(Policy = ...)]
[HttpPut("{id}")]
[Authorize(Policy = "REFERENCE_DATA_COMPANY_TYPES_UPDATE")]
[ProducesResponseType(typeof(Result), 200)]
[ProducesResponseType(typeof(Result), 400)]
[ProducesResponseType(typeof(Result), 404)]
[ProducesResponseType(typeof(Result), 409)]
public override Task<IActionResult> Update(Guid id, UpdateCompanyTypeCommand command)
Parameters
idGuidcommandUpdateCompanyTypeCommand
Returns
- Task<IActionResult>