예제 #1
0
        public ActionResult CreateLogin(LoginViewModel viewModel)
        {
            if (ModelState.IsValid)
            {
                Login login = new Login()
                {
                    Username = viewModel.Username,
                    Password = viewModel.Password
                };
                _dataService.CreateLogin(login);
            }

            return(View(ViewNames.CreateLogin, viewModel));
        }
예제 #2
0
        public ActionResult Create(AccountViewModel viewModel)
        {
            if (ModelState.IsValid)
            {
                if (_dataService.GetLoginByUsername(viewModel.UserName) == null)
                {
                    string salt = SimpleHash.GetSalt(32);

                    Login login = viewModel.ConvertToEntity();
                    login.Password     = SimpleHash.MD5(login.Password, salt);
                    login.PasswordSalt = salt;
                    _dataService.CreateLogin(login);

                    return(RedirectToAction("Create", "Member", new { loginId = login.Id }));
                }
                else
                {
                    ModelState.AddModelError("UserName", "An Account with this username already exists in the database");
                }
            }

            return(View(viewModel));
        }