public IActionResult OnPostEdit(EditInventory command) { var operationResult = new OperationResult(); if (ModelState.IsValid) { operationResult = _inventoryApplication.Edit(command); } return(new JsonResult(operationResult)); }
public OperationResult Edit(EditInventory command) { var operation = new OperationResult(); var inventory = _inventoryRepository.Get(command.Id); if (inventory == null) { return(operation.Failed(ApplicationMessages.RecordNotFound)); } if (_inventoryRepository.Exists(x => x.ProductId == command.ProductId && x.Id != command.Id)) { return(operation.Failed(ApplicationMessages.DuplicatedRecord)); } inventory.Edit(command.ProductId, command.UnitPrice); _inventoryRepository.SaveChanges(); return(operation.Succeeded()); }
public OperationResult Edit(EditInventory command) { var operationResult = new OperationResult(); var inventory = _inventoryRepository.Get(command.Id); if (inventory == null) { return(operationResult.Failed(QueryValidationMessage.NotFound)); } if (_inventoryRepository.Exists(i => i.ProductId == command.ProductId && i.Id != command.Id)) { return(operationResult.Failed(QueryValidationMessage.DuplicateRecord)); } inventory.Edit(command.ProductId, command.UnitPrice); _inventoryRepository.SaveChanges(); return(operationResult.Succeeded()); }
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()); }
public JsonResult OnPostEdit(EditInventory command) { var result = _inventoryApplication.Edit(command); return(new JsonResult(result)); }