public ActionResult SignUp(User User)
        {
            var hashedPassword = EncryptionService.CreateHash(User.Password);

            User.Password  = hashedPassword;
            User.CreatedOn = DateTime.Now;
            if (User.IsSuperAdmin == null)
            {
                User.IsSuperAdmin = false;
            }
            var user = db.User.Add(User);

            db.SaveChanges();
            var role = new Role();

            role.Uid = user.Uid;
            if (user.IsSuperAdmin == false)
            {
                role.RoleName = "User";
            }
            else
            {
                role.RoleName = "Super Admin";
            }
            var roles = db.Role.Add(role);

            if (user != null)
            {
                return(View("Login"));
            }

            return(View());
        }
Exemplo n.º 2
0
        public void ThereIsAreFollowingUsersInTheSystem(Table table)
        {
            var accounts = new List <Account>();
            var service  = new EncryptionService();

            foreach (var tableRow in table.Rows)
            {
                accounts.Add(new Account
                {
                    UserName = tableRow[0],
                    Password = service.CreateHash(tableRow[1])
                });
            }

            StateAdapter.InitAccounts(accounts);
        }