Esempio n. 1
0
 public ActionResult Edit(int id)
 {
     EditModel model = new EditModel();
     Member member = DB_Service.Set<Member>().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.Member_Profile.AvtarUrl;
     model.CityCode = member.Member_Profile.CityCode;
     model.Sex = member.Member_Profile.Sex.Value;
     model.Borthday = member.Member_Profile.Borthday.Value;
     model.Description = member.Member_Profile.Description;
     List<int> GroupList = new List<int>();
     GroupList.Add(model.GroupID);
     ViewBag.Data_GroupID = GetForeignData(GroupList);
     return View(model);
 }
Esempio n. 2
0
 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
         {
             Member member = DB_Service.Set<Member>().Include(x => x.Member_Profile).Single(x => x.MemberID == model.MemberID);
             DB_Service.Attach<Member>(member);
             member.GroupID = model.GroupID;
             member.Member_Profile.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 RedirectToAction("index");
         }
         catch (Exception ex)
         {
             ViewBag.Message = ex.Message;
             return View(model);
         }
     }
     else
     {
         return View(model);
     }
 }