public ActionResult EditPersonal(EditPersonalModel model) { var userid = UserHelper.GetUserId(HttpContext); long gid = GuideUserSvc.GetGid((long)userid); bool isok = UserSvc.UpdateUser((long)userid, model.nickname, model.phonenum, model.gender, model.password, model.email); if (gid == null) { if (isok) { return(Json(new AjaxResult { status = "ok" })); } return(Json(new AjaxResult { status = "error", errorMsg = "保存失败" })); } bool issuccess = GuideSvc.UpdateGuide(gid, model.school, model.intro); if (issuccess && isok) { return(Json(new AjaxResult { status = "ok" })); } return(Json(new AjaxResult { status = "error", errorMsg = "保存失败" })); }
// // GET: /Account/ManageDetails public ActionResult ManageDetails() { using (StoreDbContext db = new StoreDbContext()) { if (User.Identity.IsAuthenticated) { var profile = db.UserProfiles.FirstOrDefault(p => p.UserId == WebSecurity.CurrentUserId); if (profile != null) { EditPersonalModel view = new EditPersonalModel { Email = profile.Email, FirstName = profile.FirstName, HouseNumber = profile.AddressHouse, PhoneNumber = profile.Phonenumber, SecondName = profile.LastName, Street = profile.AddressStreet, Town = profile.AddressTown, ZipCode = profile.AddressZip, }; return(View(view)); } } return(View()); } }
public ActionResult ManageDetails(EditPersonalModel model) { if (ModelState.IsValid) { // ChangePassword will throw an exception rather than return false in certain failure scenarios. using (StoreDbContext db = new StoreDbContext()) { var profile = db.UserProfiles.FirstOrDefault(p => p.UserId == WebSecurity.CurrentUserId); profile.FirstName = model.FirstName; profile.LastName = model.SecondName; profile.Email = model.Email; profile.AddressStreet = model.Street; profile.AddressHouse = model.HouseNumber; profile.AddressZip = model.ZipCode; profile.AddressTown = model.Town; profile.Phonenumber = model.PhoneNumber; db.SaveChanges(); } } return(RedirectToAction("ManageDetails")); }