Table of Contents

Class StockTransfersController

Namespace
KadicErp.WebApi.Controllers.Inventory
Assembly
KadicErp.WebApi.dll
[Route("api/inventory/stock-transfers")]
[Authorize]
public class StockTransfersController : GenericCrudControllerBase<StockTransferDto, CreateStockTransferCommand, UpdateStockTransferCommand, GetStockTransferByIdQuery, GetStockTransfersQuery>
Inheritance
object
ControllerBase
GenericCrudControllerBase<StockTransferDto, CreateStockTransferCommand, UpdateStockTransferCommand, GetStockTransferByIdQuery, GetStockTransfersQuery>
StockTransfersController
Inherited Members
GenericCrudControllerBase<StockTransferDto, CreateStockTransferCommand, UpdateStockTransferCommand, GetStockTransferByIdQuery, GetStockTransfersQuery>.Sender
GenericCrudControllerBase<StockTransferDto, CreateStockTransferCommand, UpdateStockTransferCommand, GetStockTransferByIdQuery, GetStockTransfersQuery>.CreateGetByIdQuery(Guid)
GenericCrudControllerBase<StockTransferDto, CreateStockTransferCommand, UpdateStockTransferCommand, GetStockTransferByIdQuery, GetStockTransfersQuery>.CreateGetAllQuery(PaginatorRequestDto, bool?)
GenericCrudControllerBase<StockTransferDto, CreateStockTransferCommand, UpdateStockTransferCommand, GetStockTransferByIdQuery, GetStockTransfersQuery>.SetCommandId(UpdateStockTransferCommand, Guid)
GenericCrudControllerBase<StockTransferDto, CreateStockTransferCommand, UpdateStockTransferCommand, GetStockTransferByIdQuery, GetStockTransfersQuery>.HandleCommandResult(Result)
GenericCrudControllerBase<StockTransferDto, CreateStockTransferCommand, UpdateStockTransferCommand, GetStockTransferByIdQuery, GetStockTransfersQuery>.HandleCommandResult<T>(Result<T>, string)
GenericCrudControllerBase<StockTransferDto, CreateStockTransferCommand, UpdateStockTransferCommand, GetStockTransferByIdQuery, GetStockTransfersQuery>.Create(CreateStockTransferCommand)
GenericCrudControllerBase<StockTransferDto, CreateStockTransferCommand, UpdateStockTransferCommand, GetStockTransferByIdQuery, GetStockTransfersQuery>.Update(Guid, UpdateStockTransferCommand)
GenericCrudControllerBase<StockTransferDto, CreateStockTransferCommand, UpdateStockTransferCommand, GetStockTransferByIdQuery, GetStockTransfersQuery>.GetById(Guid)
GenericCrudControllerBase<StockTransferDto, CreateStockTransferCommand, UpdateStockTransferCommand, GetStockTransferByIdQuery, GetStockTransfersQuery>.GetAll(PaginatorRequestDto, bool?)

Constructors

StockTransfersController(ISender, ICurrentUser, ITenantIdContext, IStringLocalizer<GeneralMessages>)

public StockTransfersController(ISender sender, ICurrentUser currentUser, ITenantIdContext tenantContext, IStringLocalizer<GeneralMessages> localizer)

Parameters

sender ISender
currentUser ICurrentUser
tenantContext ITenantIdContext
localizer IStringLocalizer<GeneralMessages>

Methods

BulkTransfer(CreateStockTransferBulkCommand, CancellationToken)

[HttpPost("bulk")]
[Authorize(Policy = "INVENTORY_STOCK_TRANSFERS_CREATE")]
[ProducesResponseType(typeof(Result<Guid>), 201)]
[ProducesResponseType(typeof(Result), 400)]
[ProducesResponseType(typeof(Result), 409)]
public Task<IActionResult> BulkTransfer(CreateStockTransferBulkCommand command, CancellationToken cancellationToken = default)

Parameters

command CreateStockTransferBulkCommand
cancellationToken CancellationToken

Returns

Task<IActionResult>

Create(CreateStockTransferCommand)

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

Parameters

command CreateStockTransferCommand

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>

GetAll(PaginatorRequestDto, CancellationToken)

[HttpGet]
[Authorize(Policy = "INVENTORY_STOCK_TRANSFERS_VIEW")]
[ProducesResponseType(typeof(PaginatorResponseDto<StockTransferDto>), 200)]
[ProducesResponseType(typeof(Error), 400)]
public Task<IActionResult> GetAll(PaginatorRequestDto paginator, CancellationToken cancellationToken = default)

Parameters

paginator PaginatorRequestDto
cancellationToken CancellationToken

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

Parameters

id Guid

Returns

Task<IActionResult>

GetByItem(Guid, CancellationToken)

[HttpGet("by-item/{itemId:guid}")]
[Authorize(Policy = "INVENTORY_STOCK_TRANSFERS_VIEW")]
[ProducesResponseType(typeof(IReadOnlyList<StockTransferDto>), 200)]
public Task<IActionResult> GetByItem(Guid itemId, CancellationToken cancellationToken = default)

Parameters

itemId Guid
cancellationToken CancellationToken

Returns

Task<IActionResult>

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

Parameters

command UpdateStockTransferCommand
id Guid

Returns

UpdateStockTransferCommand

Update(Guid, UpdateStockTransferCommand)

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:guid}")]
[Authorize(Policy = "INVENTORY_STOCK_TRANSFERS_UPDATE")]
[ProducesResponseType(typeof(Result), 200)]
[ProducesResponseType(typeof(Result), 400)]
[ProducesResponseType(typeof(Result), 404)]
[ProducesResponseType(typeof(Result), 409)]
public override Task<IActionResult> Update(Guid id, UpdateStockTransferCommand command)

Parameters

id Guid
command UpdateStockTransferCommand

Returns

Task<IActionResult>