public ActionResult <BaseResponse> Update(ProductRequest request) { var response = new BaseResponse(); try { var product = _dacProduct.Single(request.Id); if (product == null) { throw new Exception("data is not exist"); } var isImageChanges = string.Join(".", product.ProductImages.Select(p => p.Url)) != string.Join(".", request.Images); if (request.Images.Any() && isImageChanges) { _dacProductImage.DeleteWhere(p => p.ProductId.Equals(product.Id)); product.ProductImages = CreateProductImage(request.Images, product.Id); } if (request.Name != product.Name) { product.Name = request.Name; } if (request.CategoryId != product.CategoryId) { product.CategoryId = request.CategoryId; } if (request.Price != product.Price) { product.Price = request.Price; } _dacProduct.Update(product); _dacProduct.Commit(); response.Status.SetSuccess(); } catch (Exception e) { Console.WriteLine(e); response.Status.SetError(e); } return(response); }