Exemplo n.º 1
0
        public async Task <IActionResult> CreateTransferAsync(
            [FromBody] CreateMedicineBatchTransferCommand command
            )
        {
            try
            {
                if (command.FromTenantId == command.ToTenantId)
                {
                    return(BadRequest("FromTenantId cannot be equal to ToTenantId."));
                }
                if (command.Quantity <= 0)
                {
                    return(BadRequest("Quantity cannot be less than 0"));
                }

                var result = await medicineBatchTransferService.Create(
                    command.MedicineBatchId,
                    command.FromTenantId,
                    command.ToTenantId,
                    command.Quantity);

                return(Ok(new { MedicineBatchTransferId = result }));
            }
            catch (Exception ex)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, ex));
            }
        }
Exemplo n.º 2
0
        public async Task <IActionResult> UpdateMedicineBatchTransferAsync(
            Guid id,
            [FromBody] CreateMedicineBatchTransferCommand command)
        {
            try
            {
                await medicineBatchTransferService.Update(
                    id,
                    command.MedicineBatchId,
                    command.FromTenantId,
                    command.ToTenantId,
                    command.Quantity,
                    command.IsConfirmed);

                return(Ok());
            }
            catch (Exception ex)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, ex));
            }
        }