public ActionResult Edit(int id) { EditModel model = new EditModel(); Member member = memberService.FindMemberWithProfile(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.CityCode; 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 Member Update(EditModel model) { Member member = FindMemberWithProfile(model.MemberID); DB_Service.Attach<Member>(member); member.GroupID = model.GroupID; member.AvtarUrl = model.AvtarUrl; member.Member_Profile.CityCode = model.CityCode; member.Member_Profile.Sex = model.Sex; member.Member_Profile.Borthday = model.Borthday; member.Member_Profile.Description = model.Description; DB_Service.Commit(); return member; }
public ActionResult Edit(EditModel model) { 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); return RedirectToAction("index"); } catch (Exception ex) { ViewBag.Message = ex.Message; return View(model); } } else { return View(model); } }