示例#1
0
        public ActionResult Edit(int id = 0)
        {
            DiscountModel model = null;

            using (DiscountContext context = new DiscountContext())
            {
                model = context.GetDiscount(id);
                ViewBag.DiscountKinds = context.GetDiscountKinds();
            }
            return(View(model));
        }
示例#2
0
        public ActionResult New()
        {
            DiscountModel model = new DiscountModel()
            {
                DiscountId = 0,
                Name       = "",
                ValidFrom  = DateTime.Now,
                ValidTo    = DateTime.Now
            };

            using (DiscountContext context = new DiscountContext())
            {
                ViewBag.DiscountKinds = context.GetDiscountKinds();
            }
            return(View("Edit", model));
        }
示例#3
0
 public ActionResult Edit(DiscountModel model)
 {
     if (!ModelState.IsValid)
     {
         using (DiscountContext context = new DiscountContext())
         {
             ViewBag.DiscountKinds = context.GetDiscountKinds();
         }
         return(View("Edit", model));
     }
     else
     {
         using (DiscountContext context = new DiscountContext())
         {
             context.Edit(model);
         }
         return(RedirectToAction("Index"));
     }
 }