Example #1
0
        public StartupViewModel PrepareStartupViewData()
        {
            var setupConfig        = SetupHelper.LoadSetup();
            var model              = new StartupViewModel();
            var moduleSiteMenuList = new List <SiteMenuItem>();

            model.Default     = setupConfig.StartupUrl;
            model.StartupType = setupConfig.StartupType;

            model.Pages      = new SelectList(_pageService.LoadAllActive(), "Slug", "Title", GetSlug(setupConfig.StartupUrl));
            model.Posts      = new SelectList(_postService.LoadAllByPostStatusAndDate(NccPost.NccPostStatus.Published, DateTime.Now), "Slug", "Title", GetSlug(setupConfig.StartupUrl));
            model.Categories = new SelectList(_categoryService.LoadAllActive(), "Slug", "Title", GetSlug(setupConfig.StartupUrl));
            AdminMenuHelper.ModulesSiteMenus().Select(x => x.Value).ToList().ForEach(x => moduleSiteMenuList.AddRange(x));
            model.ModuleSiteMenus = new SelectList(moduleSiteMenuList, "Url", "Url", setupConfig.StartupUrl);

            ViewBag.DefaultChecked  = "";
            ViewBag.PageChecked     = "";
            ViewBag.CategoryChecked = "";
            ViewBag.PostChecked     = "";
            ViewBag.ModuleChecked   = "";

            if (setupConfig.StartupType == StartupTypes.Page)
            {
                ViewBag.PageChecked = "checked";
            }
            else if (setupConfig.StartupType == StartupTypes.Post)
            {
                ViewBag.PostChecked = "checked";
            }
            else if (setupConfig.StartupType == StartupTypes.Category)
            {
                ViewBag.CategoryChecked = "checked";
            }
            else if (setupConfig.StartupType == StartupTypes.Module)
            {
                ViewBag.ModuleChecked = "checked";
            }
            else
            {
                ViewBag.DefaultChecked = "checked";
            }

            return(model);
        }