public ActionResult Edit(Guid id) { OfficialAccount off = new OfficialAccount_BLL().Get(a => a.AccountID == id); AutoMapper.Mapper.CreateMap <OfficialAccount, OfficialAccount_ViewModel>(); OfficialAccount_ViewModel model = AutoMapper.Mapper.Map <OfficialAccount_ViewModel>(off); return(View(model)); }
public ActionResult Edit(OfficialAccount_ViewModel model) { AutoMapper.Mapper.CreateMap <OfficialAccount_ViewModel, OfficialAccount>(); OfficialAccount newmodel = AutoMapper.Mapper.Map <OfficialAccount>(model); OfficialAccount_BLL bll = new OfficialAccount_BLL(); if (bll.Update(newmodel) > 0) { return(RedirectToAction("MyList")); } else { ModelState.AddModelError("", "修改失败,请稍后再试!"); return(View(model)); } }