public void Update(Product entity, int[] categoriesID) { var product = _context.Products .Include(x => x.ProductCategories) .Where(x => x.Id == entity.Id) .FirstOrDefault(); if (product != null) { product.Name = entity.Name; product.Image = entity.Image; product.Price = entity.Price; product.Description = entity.Description; product.ProductCategories = categoriesID.Select(catId => new ProductCategory() { CategoryId = catId, ProductId = entity.Id }).ToList(); _context.SaveChanges(); } }
public override void Update(Card entity) { _context.Cards.Update(entity); _context.SaveChanges(); }