示例#1
0
        public ICommandResult handle(Guid Id)
        {
            var command = _productRepository.GetById(Id);

            //fast fail validations

            if (command == null)
            {
                return(new CommandResult("Command invalid", false, command));
            }

            _productRepository.Delete(command);

            return(new CommandResult("Product Deleted", true, command));
        }
示例#2
0
        public ICommandResult handle(UpdateProductCommand command)
        {
            //fast fail validations
            command.Validate();

            if (command.Invalid)
            {
                return(new CommandResult("Command invalid", false, command.Notifications));
            }

            var product = _productRepository.GetById(command.Id);

            product.Name       = command.Name;
            product.Price      = command.Price;
            product.Reviews    = command.Reviews;
            product.Amount     = command.Amount;
            product.AnimalType = command.AnimalType;

            _productRepository.Update(product);

            return(new CommandResult("Product created", true, command));
        }
示例#3
0
 public async Task <ActionResult> GetById(Guid Id)
 {
     return(Ok(_productRespository.GetById(Id)));
 }
示例#4
0
 public Product GetProductById(Guid Id)
 {
     return(_iRespository.GetById(Id));
 }