public OperationResult Create(CreateInventory command) { var operation = new OperationResult(); if (_inventoryrepository.Exists(x => x.ProductId == command.ProductId)) { return(operation.Failed(ApplicationMessages.DuplicatedRecord)); } var inventory = new Inventory(command.ProductId, command.UnitPrice); _inventoryrepository.Create(inventory); _inventoryrepository.Save(); return(operation.Succeeded()); }
public OperationResult Create(CreateInventory command) { var operationResult = new OperationResult(); if (_inventoryRepository.Exists(i => i.ProductId == command.ProductId)) { return(operationResult.Failed(QueryValidationMessage.DuplicateRecord)); } var inventory = new Inventory(command.ProductId, command.UnitPrice); _inventoryRepository.Create(inventory); _inventoryRepository.SaveChanges(); return(operationResult.Succeeded()); }
public OperationResult Create(CreateInventoryVM command) { OperationResult result = new OperationResult(); if (_inventoryRepository.IsExist(i => i.ProductId == command.ProductId && i.Price == command.Price)) { return(result.Failed(ValidateMessage.IsDuplicated)); } var inventory = new Inventory(command.ProductId, command.Price); _inventoryRepository.Create(inventory); _inventoryRepository.SaveChanges(); return(result.Succeeded()); }
public OperationResult Create(InventoryCreate create) { var operation = new OperationResult(); if (_inventoryRepository.Exists(i => i.ProductId == create.ProductId)) { return(operation.Fail(ApplicationMessages.DuplicateRecord)); } var inventory = new Inventory(create.ProductId, create.UnitPrice); _inventoryRepository.Create(inventory); _inventoryRepository.SaveChanges(); return(operation.Success()); }
public IActionResult AddUpdateItem([FromBody] InventoryDto inventoryDto) { var inventory = _mapper.Map <Inventory>(inventoryDto); try { if (inventory.Id == null) { _inventoryRepo.Create(inventory); return(Ok()); } else { _inventoryRepo.Update(inventory); return(Ok()); } } catch (AppException ex) { return(BadRequest(new { message = ex.Message })); } }
public void Create(InventoryModel inventoryModel) { _repos.Create(inventoryModel); }
public void Create(Inventory inventory) { _repository.Create(Mapping.Mapped.Map <Domain.Entities.Inventory>(inventory)); }
/// <summary> /// Create /// </summary> /// <param name="data">The record passed in.</param> /// <returns>The record created for the result.</returns> public InventoryModel Create(InventoryModel data) { var myData = repository.Create(data); return(myData); }