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.")); } }
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()); }