public ActionResult DeleteConfirmed() { var user = _usersRepositoryHandler.GetUserByEmail(FormsAuthentication.Decrypt (Request.Cookies[FormsAuthentication.FormsCookieName].Value).Name); if (user == null) { return(RedirectToAction("Index", "Main")); } _usersRepositoryHandler.Remove(user); FormsAuthentication.SignOut(); return(RedirectToAction("Login", "Account")); }
public ActionResult Register(RegisterModel model) { if (!ModelState.IsValid) { return(View(model)); } var user = Mapper.Map <BlModels.User, User> (_usersRepositoryHandler.GetUserByEmail(model.Email)); if (user == null) { _usersRepositoryHandler.Add( new BlModels.User { Email = model.Email, FirstName = model.FirstName, LastName = model.LastName, Patronymic = model.Patronymic, Role = _rolesRepositoryHandler.FindByName("User"), Position = _positionsRepositoryHandler.FindById(model.PositionId), Password = model.Password, UserName = model.Email }); return(RedirectToAction("Login", "Account")); } ModelState.AddModelError("", "Пользователь с такой почтой уже существует"); return(View(model)); }
protected BlModels.User GetUser() { var userName = FormsAuthentication.Decrypt (Request.Cookies[FormsAuthentication.FormsCookieName].Value).Name; var user = _usersRepositoryHandler.GetUserByEmail(userName); return(user); }