Esempio n. 1
0
        public ActionResult Install(Install model)
        {
            if (Globals.IsNewSite(ControllerContext.RequestContext.HttpContext))
            {
                if (ModelState.IsValid)
                {
                    using (XenonCMSContext DB = new XenonCMSContext())
                    {
                        string RequestDomain = Globals.GetRequestDomain(ControllerContext.RequestContext.HttpContext);
                        Site Site = new Site();
                        Site.AdminIPs = new List<SiteAdminIP>();
                        Site.BlogPosts = new List<SiteBlogPost>();
                        Site.Pages = new List<SitePage>();

                        SiteAdminIP NewAdminIP = new SiteAdminIP();
                        NewAdminIP.Address = ControllerContext.RequestContext.HttpContext.Request.UserHostAddress;
                        Site.AdminIPs.Add(NewAdminIP);

                        SiteBlogPost NewBlogPost = new SiteBlogPost();
                        NewBlogPost.DateLastUpdated = DateTime.Now;
                        NewBlogPost.DatePosted = DateTime.Now;
                        NewBlogPost.FullPostText = "XenonCMS has been successfully installed and is ready for use on " + RequestDomain + "!";
                        NewBlogPost.Slug = "xenoncms-installed";
                        NewBlogPost.Title = "XenonCMS Installed";
                        Site.BlogPosts.Add(NewBlogPost);

                        Site.ContactEmail = "contact@" + RequestDomain;
                        Site.Domain = RequestDomain;
                        Site.NavBarInverted = false;

                        SitePage NewPageHome = new SitePage();
                        NewPageHome.DateAdded = DateTime.Now;
                        NewPageHome.DateLastUpdated = DateTime.Now;
                        NewPageHome.DisplayOrder = 1;
                        NewPageHome.Html = "XenonCMS has been successfully installed and is ready for use on " + RequestDomain + "!";
                        NewPageHome.Layout = "JumbotronNoSidebar";
                        NewPageHome.Text = "Home";
                        NewPageHome.Slug = "home";
                        NewPageHome.ParentId = 0;
                        NewPageHome.RequireAdmin = false;
                        NewPageHome.RightAlign = false;
                        NewPageHome.ShowInMenu = true;
                        NewPageHome.ShowTitleOnPage = true;
                        NewPageHome.Title = "XenonCMS Installed";
                        Site.Pages.Add(NewPageHome);

                        SitePage NewPageBlog = new SitePage();
                        NewPageBlog.DateAdded = DateTime.Now;
                        NewPageBlog.DateLastUpdated = DateTime.Now;
                        NewPageBlog.DisplayOrder = 2;
                        NewPageBlog.Html = "N/A";
                        NewPageBlog.Layout = "NormalSidebar";
                        NewPageBlog.Text = "Blog";
                        NewPageBlog.Slug = "blog";
                        NewPageBlog.ParentId = 0;
                        NewPageBlog.RequireAdmin = false;
                        NewPageBlog.RightAlign = false;
                        NewPageBlog.ShowInMenu = true;
                        NewPageBlog.ShowTitleOnPage = true;
                        NewPageBlog.Title = "Blog";
                        Site.Pages.Add(NewPageBlog);

                        SitePage NewPageContact = new SitePage();
                        NewPageContact.DateAdded = DateTime.Now;
                        NewPageContact.DateLastUpdated = DateTime.Now;
                        NewPageContact.DisplayOrder = 3;
                        NewPageContact.Html = "N/A";
                        NewPageContact.Layout = "NormalSidebar";
                        NewPageContact.Text = "Contact";
                        NewPageContact.Slug = "contact";
                        NewPageContact.ParentId = 0;
                        NewPageContact.RequireAdmin = false;
                        NewPageContact.RightAlign = false;
                        NewPageContact.ShowInMenu = true;
                        NewPageContact.ShowTitleOnPage = true;
                        NewPageContact.Title = "Contact";
                        Site.Pages.Add(NewPageContact);

                        Site.Sidebar = "<div class=\"panel panel-default\"><div class=\"panel-heading\"><h3 class=\"panel-title\">XenonCMS Installed</h3></div><div class=\"panel-body\">XenonCMS has been successfully installed and is ready for use on " + RequestDomain + "!</div></div>";
                        Site.Theme = "Cerulean";
                        Site.Title = RequestDomain;

                        DB.Sites.Add(Site);
                        DB.SaveChanges();

                        DatabaseCache.AddSite(ControllerContext.RequestContext.HttpContext, Site);
                        DatabaseCache.ResetAdminIPs(ControllerContext.RequestContext.HttpContext);
                        DatabaseCache.ResetBlogPosts(ControllerContext.RequestContext.HttpContext);
                        DatabaseCache.ResetNavMenuItems(ControllerContext.RequestContext.HttpContext);
                        DatabaseCache.ResetSidebars(ControllerContext.RequestContext.HttpContext);
                    }

                    return RedirectToAction("Index");
                }
                else
                {
                    return View(model);
                }
            }
            else
            {
                return RedirectToAction("Index");
            }
        }
Esempio n. 2
0
        public ActionResult Install(Install model)
        {
            if (Caching.GetSite() == null)
            {
                if (ModelState.IsValid)
                {
                    using (ApplicationDbContext DB = new ApplicationDbContext())
                    {
                        string RequestDomain = Globals.GetRequestDomain();
                        Site Site = new Site();

                        Site.ContactEmail = "website@" + RequestDomain;
                        Site.Domain = RequestDomain;
                        Site.NavBarInverted = false;
                        Site.Sidebar = "<div class=\"panel panel-default\"><div class=\"panel-heading\"><h3 class=\"panel-title\">XenonCMS Installed</h3></div><div class=\"panel-body\">XenonCMS has been successfully installed and is ready for use on " + RequestDomain + "!</div></div>";
                        Site.Theme = "Cerulean";
                        Site.Title = RequestDomain;

                        Site.BlogPosts.Add(new SiteBlogPost() {
                            DateLastUpdated = DateTime.Now,
                            DatePosted = DateTime.Now,
                            FullPostText = "XenonCMS has been successfully installed and is ready for use on " + RequestDomain + "!",
                            Slug = "xenoncms-installed",
                            Title = "XenonCMS Installed"

                        });

                        Site.Pages.Add(new SitePage() {
                            DateAdded = DateTime.Now,
                            DateLastUpdated = DateTime.Now,
                            DisplayOrder = 1,
                            Html = "<div class=\"jumbotron\"><h2>XenonCMS Installed</h2><p>XenonCMS has been successfully installed and is ready for use on " + RequestDomain + "!</p></div>",
                            LinkText = "Home",
                            ParentId = null,
                            RequireAdmin = false,
                            RightAlign = false,
                            ShowInMenu = true,
                            ShowTitleOnPage = false,
                            Slug = "home",
                            Title = "XenonCMS Installed"
                        });

                        Site.Pages.Add(new SitePage()
                        {
                            DateAdded = DateTime.Now,
                            DateLastUpdated = DateTime.Now,
                            DisplayOrder = 2,
                            Html = null,
                            LinkText = "Blog",
                            ParentId = null,
                            RequireAdmin = false,
                            RightAlign = false,
                            ShowInMenu = true,
                            ShowTitleOnPage = true,
                            Slug = "blog",
                            Title = RequestDomain + " Blog"
                        });

                        Site.Pages.Add(new SitePage()
                        {
                            DateAdded = DateTime.Now,
                            DateLastUpdated = DateTime.Now,
                            DisplayOrder = 3,
                            Html = null,
                            LinkText = "Contact",
                            ParentId = null,
                            RequireAdmin = false,
                            RightAlign = false,
                            ShowInMenu = true,
                            ShowTitleOnPage = true,
                            Slug = "contact",
                            Title = "Contact Form"
                        });

                        DB.Sites.Add(Site);
                        DB.SaveChanges();

                        Caching.ResetSite();
                        Caching.ResetBlogPosts();
                        Caching.ResetPages();
                        // TODOXXX Caching.ResetSidebars();
                    }

                    return Redirect("~");
                }
                else
                {
                    return View(model);
                }
            }
            else
            {
                return Redirect("~");
            }
        }