public async Task Update(ConcurrencyToken <Product> product) { var original = await _context.Products.SingleAsync(p => p.Id == product.Entity.Id.Value); original.Price = product.Entity.Price.Value; original.Title = product.Entity.Title.Value; _context.UpdateWithToken <Product, ProductDto, Guid>(product, original); }
public async Task Update(ConcurrencyToken <ProductCategory> productCategory) { await CheckForDoublesOrThrow(productCategory.Entity); var original = await _context.ProductCategories.SingleAsync(p => p.Id == productCategory.Entity.Id.Value); original.ShortDescription = productCategory.Entity.ShortDescription.Value; original.Title = productCategory.Entity.Title.Value; var originalImageId = original.ImageId; original.ImageId = productCategory.Entity.Image.Value; _context.UpdateWithToken <ProductCategory, ProductCategoryDto, Guid>(productCategory, original); if (productCategory.Entity.Image.Value != originalImageId && originalImageId != null) { await _files.Remove(originalImageId.Value, original.Id); } }