public void UpdateAccount(RegisterModel model) { try { UserProfile target = db.UserProfiles.Where(u => u.UserName == model.UserName).FirstOrDefault(); target.FullName = model.FullName; target.Phone = model.Phone; target.Email = model.Email; target.Administrator = model.Administrator; target.Coordinator = model.Coordinator; db.Entry(target).State = System.Data.EntityState.Modified; db.SaveChanges(); } catch (Exception e) { throw e; } }
public ActionResult Register(RegisterModel model) { if (ModelState.IsValid) { // Attempt to register the user try { WebSecurity.CreateUserAndAccount(model.UserName, model.Password); model.Coordinator = false; model.Administrator = false; UpdateAccount(model); //WebSecurity.Login(model.UserName, model.Password); return RedirectToAction("Manage", "Account"); } catch (MembershipCreateUserException e) { ModelState.AddModelError("", ErrorCodeToString(e.StatusCode)); } } // If we got this far, something failed, redisplay form return View(model); }