// // 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)); }
// // 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)); }
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")); } }