public ActionResult Create(User model, string password) { if (string.IsNullOrEmpty(password)) ModelState.AddModelError("Password", "You must provide a password for this user."); if (!ModelState.IsValid) { ViewBag.UserTypesSelectList = new SelectList(_userTypeRepo.GetAll(), "ID", "Name", (int)UserTypeEnum.Volunteer); return View(model); } WebSecurity.CreateUserAndAccount(model.Email, password, new { UserTypeId = model.UserTypeID, CreatedTimeUTC = DateTime.UtcNow, DisplayName = model.DisplayName, Phone = model.Phone }, false); return RedirectToAction("Index"); }
public ActionResult Edit(User model, string password, int existingUserTypeID) { if (!ModelState.IsValid) { ViewBag.UserTypesSelectList = new SelectList(_userTypeRepo.GetAll(), "ID", "Name", (int)UserTypeEnum.Volunteer); return View(model); } if (!string.IsNullOrEmpty(password)) { string token = WebSecurity.GeneratePasswordResetToken(model.Email); WebSecurity.ResetPassword(token, password); } // in case of editing same user, the UserTypeID is not sent since select is disabled if (model.UserTypeID == 0) model.UserTypeID = existingUserTypeID; _userRepo.Update(model); return RedirectToAction("Index"); }
public ActionResult CreateOrUpdateUser(User user) { throw new NotImplementedException(); }