示例#1
0
        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();
        }
示例#2
0
 public ActionResult EditDiscount(Discount discount)
 {
     SaveDiscount(discount);
     TempData["message"] = string.Format("{0} has been saved", discount.Id);
     return RedirectToAction("Index", "Admin");
 }