Example #1
0
        public SiteModel(SiteContainer context, string contentName, bool showContentItems = false)
        {
            Title = "Ольга Шитова";
            PageTitle = "Ольга Шитова";
            if (contentName == null)
            {
                Content = context.Content.First(c => c.MainPage);
            }
            else
            {
                Content = context.Content.FirstOrDefault(c => c.Name == contentName);
                if (Content == null)
                {
                    throw new HttpNotFoundException();
                }
            }

            if (!string.IsNullOrEmpty(Content.Title))
            {
                if (Content.Title != PageTitle)
                    PageTitle += " » " + Content.Title;
                Title = Content.Title;
            }

            SeoDescription = Content.SeoDescription;
            SeoKeywords = Content.SeoKeywords;

            if (Content.MainPage)
            {
                IsHomePage = true;
            }


            
            if (showContentItems)
            {
                HasContentItems = true;
                ContentItems = context.ContentItem.Include("ContentItemImages").OrderBy(ci => ci.SortOrder).ToList();
            }

            var contents = context.Content.Where(c => !c.MainPage).ToList();

            Menu = new Menu();
            Menu.AddRange(contents.Select(content => new MenuItem {ContentId = content.Id, ContentName = content.Name, Current = content.Name == contentName, SortOrder = content.SortOrder, Title = content.Title}));
        }
Example #2
0
 /// <summary>
 /// Create a new Content object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="name">Initial value of the Name property.</param>
 /// <param name="title">Initial value of the Title property.</param>
 /// <param name="mainPage">Initial value of the MainPage property.</param>
 /// <param name="sortOrder">Initial value of the SortOrder property.</param>
 public static Content CreateContent(global::System.Int32 id, global::System.String name, global::System.String title, global::System.Boolean mainPage, global::System.Int32 sortOrder)
 {
     Content content = new Content();
     content.Id = id;
     content.Name = name;
     content.Title = title;
     content.MainPage = mainPage;
     content.SortOrder = sortOrder;
     return content;
 }
Example #3
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Content EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToContent(Content content)
 {
     base.AddObject("Content", content);
 }