public void Edit(Good entity) { var good = db.Goods.FirstOrDefault(g => g.Id == entity.Id); good.Id = entity.Id; good.Name = entity.Name; good.Description = entity.Description; good.ImageType = entity.ImageType; good.Count = entity.Count; good.Date = entity.Date; good.Image = entity.Image; good.PriceIncome = entity.PriceIncome; good.PriceSale = entity.PriceSale; good.SizeDepth = entity.SizeDepth; good.SizeHeight = entity.SizeHeight; good.SizeWidth = entity.SizeWidth; good.Color = db.Colors.Find(entity.Color.Id); good.Category =db.Categories.Find(entity.Category.Id); db.SaveChanges(); }
public void Add(Good entity) { entity.Date = DateTime.Now; db.Goods.Add(entity); db.SaveChanges(); }