Пример #1
0
 public HttpResponseMessage GetInventory()
 {
     try
     {
         /// TODO: Use a view-model.
         return(Request.CreateResponse(_inventoryRepo.Get(_connectionContext)));
     }
     catch (Exception exception)
     {
         Console.WriteLine(exception);
         return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "Failed to load inventory."));
     }
 }
Пример #2
0
        public OperationResult Edit(EditInventory command)
        {
            var operationResult = new OperationResult();

            var Inventory = _inventoryRepo.Get(command.Id);

            if (Inventory == null)
            {
                return(operationResult.Failed(ApplicationMessage.recordNotFound));
            }

            if (_inventoryRepo.Exists(c => c.ProductId == command.ProductId && c.Id != command.Id))
            {
                return(operationResult.Failed(ApplicationMessage.duplicated));
            }

            Inventory.Edit(command.ProductId, command.UnitPrice);
            _inventoryRepo.Save();
            return(operationResult.Succeeded());
        }