public ActionResult MakePageHome(int id)
        {
            Page page = Context.Pages.SingleOrDefault(x => x.Id == id);
            if (page == null)
            {
                return RedirectToRoute("HttpError404");
            }
            HomePage homePage = Context.HomePages.FirstOrDefault();
            if (homePage != null)
            {
                Context.HomePages.Remove(homePage);
            }
            homePage = new HomePage
                {
                    Page = page
                };
            Context.HomePages.Add(homePage);
            Context.SaveChanges();

            if (HttpContext.Request.UrlReferrer != null &&
                Url.IsLocalUrl(HttpContext.Request.UrlReferrer.PathAndQuery))
            {
                return Redirect(HttpContext.Request.UrlReferrer.PathAndQuery);
            }
            return RedirectToAction("AllPages");
        }
 public ActionResult CreateHomePage(PageCreateOrEditModel model)
 {
     if (ModelState.IsValid)
     {
         model.Url = model.Url.ReplaceWhiteSpacesWithHyphens();
         if (!Context.Pages.Any(p => p.Url.ToLower() == model.Url.ToLower()))
         {
             Page newPage = CreatePageByModel(model);
             Context.Pages.Add(newPage);
             HomePage homePage = new HomePage
                 {
                     Page = newPage
                 };
             Context.HomePages.Add(homePage);
             Context.SaveChanges();
             PageIndexHelper.AddOrUpdate(newPage);
             return RedirectToAction("HomePage");
         }
         ModelState.AddModelError("Url", Config.UrlErrorMessage);
     }
     model = RefillFailedPageModel(model);
     return View(model);
 }