public ActionResult Edit_Area(OfficialAccount_AreaLimit_ViewModel model) { OfficialAccount_BLL bll = new OfficialAccount_BLL(); OfficialAccount newmodel = bll.Get(a => a.AccountID == model.AccountID); newmodel.AreaLevel = model.AreaLevel; newmodel.AreaLimit = model.AreaLimit; if (bll.Update(newmodel) > 0) { return(RedirectToAction("Edit_Area")); } else { List <object> levelList = new List <object> { new { Value = "国家", Text = "国家" }, new { Value = "省份", Text = "省份" }, new { Value = "城市", Text = "城市" } }; ViewBag.LevelList = new SelectList(levelList, "Value", "Text", false); ModelState.AddModelError("", "修改失败,请稍后再试!"); return(View(model)); } }
public ActionResult Edit_Area() { if (Session["CurrentAccountID"] == null) { return(RedirectToAction("Select", "OfficialAccount", new { Area = "Admin" })); } Guid id = Guid.Parse(Session["CurrentAccountID"].ToString()); OfficialAccount off = new OfficialAccount_BLL().Get(a => a.AccountID == id); AutoMapper.Mapper.CreateMap <OfficialAccount, OfficialAccount_AreaLimit_ViewModel>(); OfficialAccount_AreaLimit_ViewModel model = AutoMapper.Mapper.Map <OfficialAccount_AreaLimit_ViewModel>(off); List <object> levelList = new List <object> { new { Value = "国家", Text = "国家" }, new { Value = "省份", Text = "省份" }, new { Value = "城市", Text = "城市" } }; ViewBag.LevelList = new SelectList(levelList, "Value", "Text", false); return(View(model)); }