예제 #1
0
        public ActionResult Register(RegisterUserViewModel user)
        {
            if (!ModelState.IsValid)
            {
                return View(user);
            }

            // First user is admin
            bool isAdmin = usersRepository.Count() == 0;

            try
            {
                WebSecurity.CreateUserAndAccount(
                    user.LoginName,
                    user.Password,
                    propertyValues: new
                    {
                        Email = user.Email,
                        IsAdmin = isAdmin
                    });

                WebSecurity.Login(user.LoginName, user.Password);
            }
            catch(InvalidOperationException ex)
            {
                log.Error(ex);
            }

            return RedirectToAction("index", "home");
        }
예제 #2
0
        public ActionResult Register()
        {
            RegisterUserViewModel user = new RegisterUserViewModel();

            if (usersRepository.Count() == 0)
            {
                user.DataBaseIsEmpty = true;
            }

            return View(user);
        }