//GET: Admin/CustomerManager/Edit public ActionResult Edit(int id) { try { var model = m_customerWorker.GetManagerCustomerEntityEdit(id); this.StatusList(model.Status); ViewBag.Gender = CustomerEntityListProvider.GetGenderList().Select(item => new SelectListItem { Text = item.Value, Value = item.Key.ToString(), Selected = item.Key == model.Gender }).ToList(); this.Pair2List <CustomerEntityEditViewModel, short, short>(CustomerEntityListProvider.GetCustomerTypeList(), p => p.CustomerType, model.CustomerType.ToString()); ViewBag.GroupId = m_customerWorker.GetCustomerGroupList(1).Select(item => new SelectListItem { Text = item.Title, Value = item.Id.ToString(), Selected = item.Id == model.GroupId }).ToList(); return(View(model)); } catch (Exception ex) { this.ShowError(ex); return(null); } }
public ActionResult Edit(CustomerEntityEditViewModel model) { if (ModelState.IsValid) { try { m_customerWorker.UpdateManagerCustomerEntityEdit(model); return(RedirectToAction("Index")); } catch (Exception ex) { ModelState.AddModelError("General", ex.Message); } } this.StatusList(model.Status); ViewBag.Gender = CustomerEntityListProvider.GetGenderList().Select(item => new SelectListItem { Text = item.Value, Value = item.Key.ToString(), Selected = item.Key == model.Gender }).ToList(); this.Pair2List <CustomerEntityEditViewModel, short, short>(CustomerEntityListProvider.GetCustomerTypeList(), p => p.CustomerType, model.CustomerType.ToString()); ViewBag.GroupId = m_customerWorker.GetCustomerGroupList(1).Select(item => new SelectListItem { Text = item.Title, Value = item.Id.ToString(), Selected = item.Id == model.GroupId }).ToList(); return(View(model)); }