Пример #1
0
 private void FillModelIfEditableFooter(CmsModel model)
 {
     if (_site.EditableSiteFoot)
     {
         model.FooterArticles = new List<Article>(_site.Pages.Single(x => x.Startpage).Articles.Where(x => x.Type == ArticleType.Sidfot));
     }
 }
Пример #2
0
 private void FillModelIfBildspel(CmsModel model)
 {
     //if (model.Page.Articles.Any(x => !x.Type.HasFlag(ArticleType.Bildspel))) return;
     foreach (var a in model.Page.Articles.Where(x => x.Type.HasFlag(ArticleType.Bildspel)))
     {
         var id = int.Parse(a.Content);
         var q = new List<Media>(_site.Medias.Where(x => x.Category.ID == id && x.Type == MediaType.Picture));
         a.BildspelsMedia = q;
     }
 }
Пример #3
0
        public ActionResult Index(string id, string param1, string param2, string param3, string param4, string param5, string param6, string param7)
        {




            var model = new CmsModel
                            {
                                Site = _site,
                                IsLoggedIn = User.Identity.IsAuthenticated,
                                User = User.Identity.IsAuthenticated ? _ctx.Users.First(x => x.UserName == User.Identity.Name) : null,
                                Tags = _ctx.Tags
                            };
            if (string.IsNullOrEmpty(id))
            {
                model.Page = _site.Pages.Single(x => x.Startpage);
                FillModelIfBildspel(model);
                FillModelIfEditableFooter(model);
                return View("/views/Customer/" + model.Site.FolderName + "/template/" + model.Page.Template.Name + "/index.cshtml", model);
            }
            model.Page = new Page { Pages = _site.Pages.Where(x => x.ParentPage == null).ToList() };
            if (model.Page == null)
                return View("error");
            foreach (var urlname in new[] { id, param1, param2, param3, param4, param5, param6, param7 })
            {
                if (string.IsNullOrEmpty(urlname))
                {
                    if (model.Page.DemandUserInRole && !User.Identity.IsAuthenticated)
                    {
                        var s = model.Page.Template.Sections.SingleOrDefault(x => x.Namn == "Content");
                        if (s != null)
                            s.Namn = "NotLoggedIn";
                    }
                    FillModelIfBildspel(model);
                    FillModelIfEditableFooter(model);
                    return View("/views/Customer/" + model.Site.FolderName + "/template/" + model.Page.Template.Name + "/index.cshtml", model);
                }

                var page = model.Page.Pages.SingleOrDefault(x => x.UrlName == urlname);
                if (page != null)
                {
                    model.PageTree.Add(page);
                    model.Page = page;
                }
                else if (model.Page.Articles.Any(x => x.UrlName == urlname))
                {
                    var a = model.Page.Articles.FirstOrDefault(x => x.UrlName == urlname);
                    if (a != null)
                        model.Article = a;
                }
                else
                {
                    if (!model.PageTree.Any())
                        model.Page = _site.Pages.Single(x => x.Startpage);
                    var s = model.Page.Template.Sections.SingleOrDefault(x => x.Namn == "Content");
                    if (s != null)
                        s.Namn = "Error";
                    FillModelIfBildspel(model);
                    FillModelIfEditableFooter(model);
                    return View("/views/Customer/" + model.Site.FolderName + "/template/" + model.Page.Template.Name + "/index.cshtml", model);
                }

            }
            return View("error");
        }