예제 #1
0
        //
        // GET: /CCard/Edit/Id
        public ActionResult Edit(int id = 0)
        {
            CCardModel model = null;

            using (CCardContext context = new CCardContext())
            {
                model = context.GetCard(id);
            }
            using (DiscountContext context = new DiscountContext())
            {
                ViewBag.DiscountGroups = context.GetGroupList();
            }
            return(View("Edit", model));
        }
예제 #2
0
        //
        // GET: /CCard/New/Id
        public ActionResult New()
        {
            CCardModel model = new CCardModel()
            {
                CardId    = 0,
                CarNumber = "",
                ValidFrom = DateTime.Now,
                ValidTo   = DateTime.Now.AddYears(1)
            };

            using (DiscountContext context = new DiscountContext())
            {
                ViewBag.DiscountGroups = context.GetGroupList();
            }
            return(View("Edit", model));
        }
예제 #3
0
 public ActionResult Edit(CCardModel model)
 {
     if (!ModelState.IsValid)
     {
         using (DiscountContext context = new DiscountContext())
         {
             ViewBag.DiscountGroups = context.GetGroupList();
         }
         return(View("Edit", model));
     }
     else
     {
         using (CCardContext context = new CCardContext())
         {
             context.Edit(model);
         }
         return(RedirectToAction("Index"));
     }
 }