Ejemplo n.º 1
0
        public IActionResult AmendLastMaterialBatchTransactionLogEntry(Guid batchId, Guid transactionId, [FromBody] TransactionLogEntryAmendingRequest transactionLogEntryAmendingRequest)
        {
            if (transactionLogEntryAmendingRequest == null)
            {
                return(HandleBadRequest("Missing amending data."));
            }

            try
            {
                string userId = GetSubject();
                InventoryService.AmendLastMaterialBatchTransaction(batchId, transactionId, transactionLogEntryAmendingRequest.Quantity, userId);
                return(NoContent());
            }
            catch (MaterialBatchNotFoundException exception)
            {
                return(HandleResourceNotFoundException(exception));
            }
            catch (NotLastLogEntryException exception)
            {
                return(HandleBadRequest(exception.Message));
            }
            catch (UnauthorizedAccessException)
            {
                return(Forbid());
            }
            catch (Exception exception)
            {
                return(HandleUnexpectedException(exception));
            }
        }