Ejemplo n.º 1
0
 // GET: Admin
 public ActionResult InitialSetup()
 {
     if (Utils.PreConfigurationHelper.IsInitialSetup(HttpContext))
     {
         StringBuilder strMessage = new StringBuilder();
         strMessage.AppendLine("Please set the initial configuration to access the database");
         var adminUser = PreConfigurationHelper.GetLocalAdminInfo(HttpContext);
         {
             if (adminUser == null)
             {
                 adminUser          = new LocalAdminInfo();
                 adminUser.Username = "******";
             }
             PreConfigurationHelper.SaveAdminUser(adminUser, HttpContext);
         }
         ViewBag.Message = strMessage.ToString();
     }
     else
     {
         if (!HttpContext.User.Identity
             .IsAuthenticated)
         {
             var routeUrl = Url.RouteUrl("InitialSetupRoute");
             return(RedirectToAction(controllerName: "Account", actionName: "Login", routeValues: new { ReturnUrl = routeUrl }));
         }
     }
     ViewModels.InitialSetup model = new ViewModels.InitialSetup();
     model.IntegratedSecuritySSPI = true;
     return(View(model));
 }
Ejemplo n.º 2
0
 public ActionResult InitialSetup(ViewModels.InitialSetup model)
 {
     if (!ModelState.IsValid)
     {
         return(View(model));
     }
     else
     {
         var adminUser = PreConfigurationHelper.GetLocalAdminInfo(HttpContext);
         if (adminUser != null)
         {
             string errors = string.Empty;
             if (SaveConnectionString(model, out errors))
             {
                 adminUser.InitialDatabaseConfigured = true;
                 PreConfigurationHelper.SaveAdminUser(adminUser, HttpContext);
                 return(RedirectToAction(actionName: "Login", controllerName: "Account"));
             }
             else
             {
                 if (!string.IsNullOrWhiteSpace(errors))
                 {
                     ViewBag.Error = errors;
                 }
                 return(View(model));
             }
         }
         else
         {
             ViewBag.Error = "There is no admin user in the local database, please create it";
             return(View(model));
         }
     }
 }