Exemple #1
0
        public async Task <ActionResult> UpdateManualStockOperation(Guid id, ManualStockOperationDto manualStockOperationDto)
        {
            var stockOperation = await _stockOperationsService.GetStockOperation(id);

            if (stockOperation is null)
            {
                return(NotFound());
            }

            await _stockItemAuthorizationLoader.AssertResourceAccessAsync(User, stockOperation.StockItemId, IsAuthorizedUserPolicy.Instance);

            if (manualStockOperationDto.StockItemId != stockOperation.StockItemId)
            {
                await _stockItemAuthorizationLoader.AssertResourceAccessAsync(User, manualStockOperationDto.StockItemId, IsAuthorizedUserPolicy.Instance);
            }

            return(await SendAndHandleOperationCommand(
                       new UpdateManualStockOperation(id, manualStockOperationDto.StockItemId, manualStockOperationDto.Quantity, User.GetUserId(), manualStockOperationDto.Comment)
                       ));
        }
Exemple #2
0
        public async Task <ActionResult <StockOperation> > GetStockOperation(Guid id)
        {
            var stockOperation = await _stockOperationsService.GetStockOperation(id);

            if (stockOperation is null)
            {
                return(NotFound());
            }

            await _stockItemAuthorizationLoader.AssertResourceAccessAsync(User, stockOperation.StockItemId, IsAuthorizedUserPolicy.Instance);

            return(stockOperation);
        }