コード例 #1
0
		private void RegisterAccount(CreateAdminAccount command) {
			ApplicationSetup.UpdateDatabaseToLatestSchema();
			
			var createUserResult = Users.Handle(command);
			
			if(!createUserResult.Succeeded) {
				throw new Exception(string.Join("\n",createUserResult.Errors));
			}
		}
コード例 #2
0
        public ActionResult CreateAdmin(CreateAdminAccount command) {
			if(ApplicationSetup.HasAdminUser()) {
				ModelState.AddModelError("admin-already-exists", "Admin already exists");
			}

            if(!ModelState.IsValid) {
                return View(command);
            }
			try {
				RegisterAccount(command);
			}
			catch(Exception e) {
				ModelState.AddModelError("exception",e);
				return View(command);
			}

            return RedirectToRoute("setup");
        }