public User GetUserDomainModel(UserViewModel userViewModel) { var user = new User(); user.Name = userViewModel.Name; user.Password = userViewModel.Password; return user; }
public UserViewModel GetUser(User user) { var userViewModel = new UserViewModel(); userViewModel.Name = user.Name; userViewModel.Password = user.Password; return userViewModel; }
public ActionResult LogIn(UserViewModel userViewModel) { if (!ModelState.IsValid) return View("Login", userViewModel); if (userService.FormIsValid(userViewModel.Name, userViewModel.Password)) { FormsAuthentication.SetAuthCookie(userViewModel.Name, false); return RedirectToAction("Index", "Home"); } else { ModelState.AddModelError("LogIn", "Login failed, please, try again"); } return View("Login", userViewModel); }
public ActionResult Registration(UserViewModel userViewModel) { if (!ModelState.IsValid) return View("Registration", userViewModel); if (!userService.UserNameIsExist(userViewModel.Name)) { var user = mapper.GetUserDomainModel(userViewModel); userService.AddUser(user); return RedirectToAction("LogIn"); } else { ModelState.AddModelError("Registration", "Registration failed, this name is exist"); } return View("Registration", userViewModel); }
public ActionResult Registration() { var userModel = new UserViewModel(); return View("Registration", userModel); }
public ActionResult LogIn() { var userModel = new UserViewModel(); return View("Login", userModel); }