public void AddMerchandise(Merchandise merchandise) { if (merchandise.ID == 0) { context.Merchandises.Add(merchandise); } else { Merchandise dbEntry = context.Merchandises .FirstOrDefault(m => m.ID == merchandise.ID); if (dbEntry != null) { dbEntry.ProductName = merchandise.ProductName; dbEntry.ProductType = merchandise.ProductType; dbEntry.ProductPrice = merchandise.ProductPrice; dbEntry.ProductClub = merchandise.ProductClub; dbEntry.ProductDescription = merchandise.ProductDescription; } } context.SaveChanges(); }