Table of Contents

Class PlansController

Namespace
KadicAuth.Api.Controllers
Assembly
KadicAuth.Api.dll
[Route("api/[controller]")]
[Authorize]
public class PlansController : GenericCrudControllerBase<PlanDto, CreatePlanCommand, UpdatePlanCommand, GetPlanByIdQuery, GetAllPlansQuery>
Inheritance
object
ControllerBase
PlansController
Inherited Members
GenericCrudControllerBase<PlanDto, CreatePlanCommand, UpdatePlanCommand, GetPlanByIdQuery, GetAllPlansQuery>.Sender
GenericCrudControllerBase<PlanDto, CreatePlanCommand, UpdatePlanCommand, GetPlanByIdQuery, GetAllPlansQuery>.CreateGetByIdQuery(Guid)
GenericCrudControllerBase<PlanDto, CreatePlanCommand, UpdatePlanCommand, GetPlanByIdQuery, GetAllPlansQuery>.CreateGetAllQuery(PaginatorRequestDto, bool?)
GenericCrudControllerBase<PlanDto, CreatePlanCommand, UpdatePlanCommand, GetPlanByIdQuery, GetAllPlansQuery>.SetCommandId(UpdatePlanCommand, Guid)
GenericCrudControllerBase<PlanDto, CreatePlanCommand, UpdatePlanCommand, GetPlanByIdQuery, GetAllPlansQuery>.HandleCommandResult(Result)
GenericCrudControllerBase<PlanDto, CreatePlanCommand, UpdatePlanCommand, GetPlanByIdQuery, GetAllPlansQuery>.HandleCommandResult<T>(Result<T>, string)
GenericCrudControllerBase<PlanDto, CreatePlanCommand, UpdatePlanCommand, GetPlanByIdQuery, GetAllPlansQuery>.Create(CreatePlanCommand)
GenericCrudControllerBase<PlanDto, CreatePlanCommand, UpdatePlanCommand, GetPlanByIdQuery, GetAllPlansQuery>.Update(Guid, UpdatePlanCommand)
GenericCrudControllerBase<PlanDto, CreatePlanCommand, UpdatePlanCommand, GetPlanByIdQuery, GetAllPlansQuery>.GetById(Guid)
GenericCrudControllerBase<PlanDto, CreatePlanCommand, UpdatePlanCommand, GetPlanByIdQuery, GetAllPlansQuery>.GetAll(PaginatorRequestDto, bool?)

Constructors

PlansController(ISender, IStringLocalizer<AuthMessages>)

public PlansController(ISender sender, IStringLocalizer<AuthMessages> localizer)

Parameters

sender ISender
localizer IStringLocalizer<AuthMessages>

Methods

Create(CreatePlanCommand)

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 = "AUTH_PLANS_CREATE")]
[ProducesResponseType(typeof(Result<Guid>), 201)]
[ProducesResponseType(typeof(Result), 400)]
[ProducesResponseType(typeof(Result), 409)]
public override Task<IActionResult> Create(CreatePlanCommand command)

Parameters

command CreatePlanCommand

Returns

Task<IActionResult>

FilterPlans(PaginatorRequestDto, Guid?)

[HttpGet("filter")]
[Authorize(Policy = "AUTH_PLANS_VIEW")]
[ProducesResponseType(typeof(PaginatorResponseDto<PlanDto>), 200)]
public Task<IActionResult> FilterPlans(PaginatorRequestDto paginator, Guid? id = null)

Parameters

paginator PaginatorRequestDto
id Guid?

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 = "AUTH_PLANS_VIEW")]
[ProducesResponseType(typeof(PaginatorResponseDto<PlanDto>), 200)]
[ProducesResponseType(typeof(Error), 400)]
public override Task<IActionResult> GetAll(PaginatorRequestDto paginator, bool? isActive = null)

Parameters

paginator PaginatorRequestDto
isActive bool?

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:guid}")]
[Authorize(Policy = "AUTH_PLANS_VIEW")]
[ProducesResponseType(typeof(PlanDto), 200)]
[ProducesResponseType(typeof(Error), 404)]
public override Task<IActionResult> GetById(Guid id)

Parameters

id Guid

Returns

Task<IActionResult>

SetCommandId(UpdatePlanCommand, 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 UpdatePlanCommand SetCommandId(UpdatePlanCommand command, Guid id)

Parameters

command UpdatePlanCommand
id Guid

Returns

UpdatePlanCommand

Update(Guid, UpdatePlanCommand)

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 = "AUTH_PLANS_UPDATE")]
[ProducesResponseType(typeof(Result), 200)]
[ProducesResponseType(typeof(Result), 400)]
[ProducesResponseType(typeof(Result), 404)]
[ProducesResponseType(typeof(Result), 409)]
public override Task<IActionResult> Update(Guid id, UpdatePlanCommand command)

Parameters

id Guid
command UpdatePlanCommand

Returns

Task<IActionResult>