Пример #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"));
     }
 }