コード例 #1
0
        public ActionResult Setup(AdministratorSetupModel model, string returnUrl)
        {
            ICardHolderService CardHolderService;

            if (ModelState.IsValid)
            {
                if (model.Password == model.RepeatPassword)
                {
                    if (model.SecondPassword == model.RepeatSecondPassword)
                    {
                        try
                        {
                            CardHolderService = new CardHolderService();
                            CardHolderService.CreateSuperUser(model.UserName, model.Password, model.SecondPassword);
                            return(RedirectToAction("AdministratorLogOn", "Account"));
                        }
                        catch (Exception Ex)
                        {
                            ModelState.AddModelError("", "Error in system initialization:" + Ex.Message);
                        }
                    }
                    else
                    {
                        ModelState.AddModelError("RepeatSecondPassword", "The password does not match.");
                    }
                }
                else
                {
                    ModelState.AddModelError("RepeatPassword", "The password does not match.");
                }
            }
            System.Threading.Thread.Sleep(1000);  // force a one second delay for security purposes
            // If we got this far, something failed, redisplay form
            return(View(model));
        }