예제 #1
0
 public User GetUserDomainModel(UserViewModel userViewModel)
 {
     var user = new User();
     user.Name = userViewModel.Name;
     user.Password = userViewModel.Password;
     return user;
 }
예제 #2
0
 public UserViewModel GetUser(User user)
 {
     var userViewModel = new UserViewModel();
     userViewModel.Name = user.Name;
     userViewModel.Password = user.Password;
     return userViewModel;
 }
예제 #3
0
 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);
 }
예제 #4
0
 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);
 }
예제 #5
0
 public ActionResult Registration()
 {
     var userModel = new UserViewModel();
     return View("Registration", userModel);
 }
예제 #6
0
 public ActionResult LogIn()
 {
     var userModel = new UserViewModel();
     return View("Login", userModel);
 }