Table of Contents

Class ExchangeRatesController

Namespace
KadicErp.WebApi.Controllers.ReferenceData
Assembly
KadicErp.WebApi.dll
[Route("api/[controller]")]
[Authorize]
public class ExchangeRatesController : GenericCrudControllerBase<ExchangeRateDto, CreateExchangeRateCommand, UpdateExchangeRateCommand, GetExchangeRateByIdQuery, GetAllExchangeRatesQuery>
Inheritance
object
ControllerBase
GenericCrudControllerBase<ExchangeRateDto, CreateExchangeRateCommand, UpdateExchangeRateCommand, GetExchangeRateByIdQuery, GetAllExchangeRatesQuery>
ExchangeRatesController
Inherited Members
GenericCrudControllerBase<ExchangeRateDto, CreateExchangeRateCommand, UpdateExchangeRateCommand, GetExchangeRateByIdQuery, GetAllExchangeRatesQuery>.Sender
GenericCrudControllerBase<ExchangeRateDto, CreateExchangeRateCommand, UpdateExchangeRateCommand, GetExchangeRateByIdQuery, GetAllExchangeRatesQuery>.CreateGetByIdQuery(Guid)
GenericCrudControllerBase<ExchangeRateDto, CreateExchangeRateCommand, UpdateExchangeRateCommand, GetExchangeRateByIdQuery, GetAllExchangeRatesQuery>.CreateGetAllQuery(PaginatorRequestDto, bool?)
GenericCrudControllerBase<ExchangeRateDto, CreateExchangeRateCommand, UpdateExchangeRateCommand, GetExchangeRateByIdQuery, GetAllExchangeRatesQuery>.SetCommandId(UpdateExchangeRateCommand, Guid)
GenericCrudControllerBase<ExchangeRateDto, CreateExchangeRateCommand, UpdateExchangeRateCommand, GetExchangeRateByIdQuery, GetAllExchangeRatesQuery>.HandleCommandResult(Result)
GenericCrudControllerBase<ExchangeRateDto, CreateExchangeRateCommand, UpdateExchangeRateCommand, GetExchangeRateByIdQuery, GetAllExchangeRatesQuery>.HandleCommandResult<T>(Result<T>, string)
GenericCrudControllerBase<ExchangeRateDto, CreateExchangeRateCommand, UpdateExchangeRateCommand, GetExchangeRateByIdQuery, GetAllExchangeRatesQuery>.Create(CreateExchangeRateCommand)
GenericCrudControllerBase<ExchangeRateDto, CreateExchangeRateCommand, UpdateExchangeRateCommand, GetExchangeRateByIdQuery, GetAllExchangeRatesQuery>.Update(Guid, UpdateExchangeRateCommand)
GenericCrudControllerBase<ExchangeRateDto, CreateExchangeRateCommand, UpdateExchangeRateCommand, GetExchangeRateByIdQuery, GetAllExchangeRatesQuery>.GetById(Guid)
GenericCrudControllerBase<ExchangeRateDto, CreateExchangeRateCommand, UpdateExchangeRateCommand, GetExchangeRateByIdQuery, GetAllExchangeRatesQuery>.GetAll(PaginatorRequestDto, bool?)

Constructors

ExchangeRatesController(ISender, IStringLocalizer<GeneralMessages>)

public ExchangeRatesController(ISender sender, IStringLocalizer<GeneralMessages> localizer)

Parameters

sender ISender
localizer IStringLocalizer<GeneralMessages>

Methods

Activate(Guid)

[HttpPatch("{id}/activate")]
[Authorize(Policy = "REFERENCE_DATA_EXCHANGE_RATES_ACTIVATE")]
public Task<IActionResult> Activate(Guid id)

Parameters

id Guid

Returns

Task<IActionResult>

Create(CreateExchangeRateCommand)

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

Parameters

command CreateExchangeRateCommand

Returns

Task<IActionResult>

CreateGetAllQuery(PaginatorRequestDto, bool?)

Creates the GetAll query. Override if your query has different constructor or additional filters.

protected override GetAllExchangeRatesQuery CreateGetAllQuery(PaginatorRequestDto paginator, bool? isActive)

Parameters

paginator PaginatorRequestDto
isActive bool?

Returns

GetAllExchangeRatesQuery

Deactivate(Guid)

[HttpPatch("{id}/deactivate")]
[Authorize(Policy = "REFERENCE_DATA_EXCHANGE_RATES_DEACTIVATE")]
public Task<IActionResult> Deactivate(Guid id)

Parameters

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.

[NonAction]
public override Task<IActionResult> GetAll(PaginatorRequestDto paginator, bool? isActive = null)

Parameters

paginator PaginatorRequestDto
isActive bool?

Returns

Task<IActionResult>

GetAllWithFilters(PaginatorRequestDto, Guid?, Guid?)

[HttpGet]
[Authorize(Policy = "REFERENCE_DATA_EXCHANGE_RATES_VIEW")]
[ProducesResponseType(typeof(PaginatorResponseDto<ExchangeRateDto>), 200)]
[ProducesResponseType(typeof(Error), 400)]
public Task<IActionResult> GetAllWithFilters(PaginatorRequestDto paginator, Guid? fromCurrencyId = null, Guid? toCurrencyId = null)

Parameters

paginator PaginatorRequestDto
fromCurrencyId Guid?
toCurrencyId Guid?

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 = "REFERENCE_DATA_EXCHANGE_RATES_VIEW")]
[ProducesResponseType(typeof(ExchangeRateDto), 200)]
[ProducesResponseType(typeof(Error), 404)]
public override Task<IActionResult> GetById(Guid id)

Parameters

id Guid

Returns

Task<IActionResult>

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

Parameters

command UpdateExchangeRateCommand
id Guid

Returns

UpdateExchangeRateCommand

Update(Guid, UpdateExchangeRateCommand)

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

Parameters

id Guid
command UpdateExchangeRateCommand

Returns

Task<IActionResult>