public ActionResult Edit(int id) { var model = new EditViewModel(); Member member = MemberService.GetALL().Include(x => x.Member_Profile).Single(x => x.MemberID == id); model.MemberID = member.MemberID; model.Email = member.Email; model.NickName = member.NickName; model.GroupID = member.GroupID; model.AvtarUrl = member.AvtarUrl; if (member.Member_Profile == null) { member.Member_Profile = new Member_Profile(); } model.CityCode = member.Member_Profile.CityCodeValue; model.Sex = member.Member_Profile.Sex; model.Borthday = member.Member_Profile.Borthday; model.Description = member.Member_Profile.Description; List<int> GroupList = new List<int>(); GroupList.Add(model.GroupID); ViewBag.Data_GroupID = GetForeignData(GroupList); return View(model); }
public ActionResult Edit(EditViewModel model) { ServiceResult result = new ServiceResult(); TempData["Service_Result"] = result; List<int> GroupList = new List<int>(); GroupList.Add(model.GroupID); var groups = GetForeignData(GroupList); ViewBag.Data_GroupID = groups; if (ModelState.IsValid) { try { MemberService.Update(model); result.Message = "添加会员信息成功!"; LogHelper.WriteLog("添加会员信息成功"); return RedirectToAction("index"); } catch (Exception ex) { result.Message = Utilities.GetInnerMostException(ex); result.AddServiceError(result.Message); LogHelper.WriteLog("添加会员信息错误", ex); return View(model); } } else { result.Message = "请检查表单是否填写完整!"; result.AddServiceError("请检查表单是否填写完整!"); return View(model); } }