Пример #1
0
        public IActionResult OnPostEdit(EditInventory command)
        {
            var operationResult = new OperationResult();

            if (ModelState.IsValid)
            {
                operationResult = _inventoryApplication.Edit(command);
            }

            return(new JsonResult(operationResult));
        }
Пример #2
0
        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());
        }
Пример #3
0
        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());
        }
Пример #4
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());
        }
Пример #5
0
        public JsonResult OnPostEdit(EditInventory command)
        {
            var result = _inventoryApplication.Edit(command);

            return(new JsonResult(result));
        }