예제 #1
0
        public HttpResponseMessage Server(ServerConfiguration serverConfiguration)
        {
            FilthConfiguration configuration = new FilthConfiguration();

            ConnectionStringState state = configuration.CheckConnection();
            var response = new HttpResponseMessage();

            switch (configuration.CheckConnection())
            {
                case ConnectionStringState.Absent:
                    if (ModelState.IsValid)
                    {
                        configuration.CreateConnectionString(serverConfiguration);

                        response = new HttpResponseMessage(HttpStatusCode.OK);
                        response.Headers.Location = new Uri(Request.RequestUri.Authority + "/?install=2");
                    } else
                        response = Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState);
                    break;
                case ConnectionStringState.Present:
                    response = new HttpResponseMessage(HttpStatusCode.OK);
                    response.Headers.Location = new Uri(Request.RequestUri.Authority + "/?install=0");
                    break;
                case ConnectionStringState.Invalid:
                    response = Request.CreateErrorResponse(HttpStatusCode.BadRequest, new Exception("I can't connect to database, either it doesn't exist or your credentials are out of date."));
                    break;
            }

            return response;
        }
예제 #2
0
        public ActionResult Index(int? install)
        {
            FilthConfiguration configuration = new FilthConfiguration();
            var state = configuration.CheckConnection();

            if (state == ConnectionStringState.Present || state == ConnectionStringState.Invalid)
                if (install == 2)
                    return View("Install-BlogConfiguration");
                else if (install == 3)
                    return View("Install-AddUser");
                else if (install == 4)
                    return View("Install-Ready");
                else
                    return View();
            else
            {
                return View("Install-ServerConfiguration");
            }
        }