コード例 #1
0
        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());
        }
コード例 #2
0
        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());
        }
コード例 #3
0
        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());
        }
コード例 #4
0
        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());
        }
コード例 #5
0
        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 }));
            }
        }
コード例 #6
0
 public void Create(InventoryModel inventoryModel)
 {
     _repos.Create(inventoryModel);
 }
コード例 #7
0
 public void Create(Inventory inventory)
 {
     _repository.Create(Mapping.Mapped.Map <Domain.Entities.Inventory>(inventory));
 }
コード例 #8
0
        /// <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);
        }