public void SaveDiscount(Discount discount) { if (discount.Id == 0) { db.Discount.Add(discount); } else { Discount dbEntry = db.Discount.Find(discount.Id); if (dbEntry != null) { dbEntry.Description = discount.Description; dbEntry.Name = discount.Name; } } db.SaveChanges(); }
public ActionResult EditDiscount(Discount discount) { SaveDiscount(discount); TempData["message"] = string.Format("{0} has been saved", discount.Id); return RedirectToAction("Index", "Admin"); }