public async Task <ICommandResult> HandleAsync(UpdateBookMarksCommand command) { command.Validate(); if (!command.IsValid) { return(new CommandResult(false, command.Errors)); } var product = await _productRepository.GetAsync(command.ProductId); if (product is null) { return(new CommandResult(false, "Product not found")); } if (product.ProductBookMarks is null || !product.ProductBookMarks.Any()) { product.ClearProductBookMarks(); } foreach (var item in command.BookMarks) { product.AddProductBookMarks(item.Code, item.Name, item.Value, item.Count); } await _productRepository.UpdateProductBookMarkAsync(product.ProductBookMarks); return(new CommandResult(true, "Product Bookmarks successfully updated.")); }
public async Task <IActionResult> UpdateProductBookMarkAsync(string id, UpdateBookMarksCommand updateCommand) { if (string.IsNullOrEmpty(updateCommand.ProductId)) { updateCommand.ProductId = id; } var result = await _updateBookMarksHandler.HandleAsync(updateCommand); if (!result.Success) { return(BadRequest(result.Message)); } return(Ok()); }
public ICommandResult Handle(UpdateBookMarksCommand command) { throw new NotImplementedException(); }