Ejemplo n.º 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));
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 3
0
 public async Task <ActionResult> GetById(Guid Id)
 {
     return(Ok(_productRespository.GetById(Id)));
 }
Ejemplo n.º 4
0
 public Product GetProductById(Guid Id)
 {
     return(_iRespository.GetById(Id));
 }