Ejemplo n.º 1
0
        public ActionResult Login(UserViewModel userViewModel = null)
        {
            if(userViewModel == null)
            {
                return this.View();
            }

            return this.View(userViewModel.User);
        }
Ejemplo n.º 2
0
        public void Login_EmptyCredentials_ReturnsLoginView()
        {
            Mock<ILoggerService> loggerService = new Mock<ILoggerService>();
            Mock<ILoginService> loginService = new Mock<ILoginService>();
            Mock<IUserService> userService = new Mock<IUserService>();
            Mock<IPasswordService> passwordService = new Mock<IPasswordService>();

            AccountController controller = new AccountController(
                loggerService.Object,
                loginService.Object,
                userService.Object,
                passwordService.Object);

            UserViewModel model = new UserViewModel();

            UserEntity user = new UserEntity();
            user.ID = Guid.NewGuid();
            user.Email = string.Empty;
            user.UserPassword = string.Empty;

            model.User = user;

            ActionResult actionResult = controller.Login(model);
        }
Ejemplo n.º 3
0
        public ActionResult Register(UserViewModel userViewModel)
        {
            if (userViewModel != null
                && ModelState.IsValid)
            {
                userViewModel.User.ID = Guid.NewGuid();
                userViewModel.User.Registered = DateTime.Now;
                userViewModel.User.LastLogin = DateTime.Now;
                userViewModel.User.Role = RoleType.NormalUser;
                userViewModel.User.InvalidPasswordCount = 0;
                userViewModel.User.InvalidPasswordDate = null;
                userViewModel.User = this._passwordService.GenerateCredentials(userViewModel.User);

                bool flag = this._userService.AddUser(userViewModel.User);

                if(flag)
                {
                    return this.RedirectToAction("Home", "User");
                }
            }

            return this.View(userViewModel);
        }
Ejemplo n.º 4
0
 public ActionResult Home(string ID)
 {
     UserViewModel model = new UserViewModel();
     model.User = this.userService.GetUser(Guid.Parse(ID));
     return this.View(model);
 }