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