コード例 #1
0
ファイル: SiteModel.cs プロジェクト: fathurxzz/aleqx
        public SiteModel(IShopRepository repository, int langId, string contentName, bool showSpecialOffers = false, string articleName = null)
        {
            
            _sw.Start();


            Title = "Active Land";

            IQueryable<Category> categories = null;

            categories = repository.GetCategories().OrderBy(c => c.SortOrder);
            Categories = categories.Include(c => c.Children).ToList();

            //Categories = repository.GetCategories().Include(x=>x.Children).ToList();
            foreach (var category in Categories)
            {
                category.CurrentLang = langId;
            }

            if (showSpecialOffers)
                SpecialOffers = GetSpecialOffers(repository, langId, int.Parse(SiteSettings.GetShopSetting("SpecialOffersQuantity")));

            Contents = repository.GetContents();

            Content = contentName != null ? (contentName == "category" ? repository.GetCatalogueContent() : repository.GetContent(contentName)) : repository.GetContent();
            MainPageBanners = repository.GetMainPageBanners();
            SiteBanners = repository.GetSiteBanners().OrderBy(p => Guid.NewGuid()).Take(2).ToList();

            MainPageInfo = new MainPageInfo();
            var authorAvatarImageSource = repository.GetSiteProperty("AuthorAvatarImageSource");
            if (authorAvatarImageSource != null)
            {
                MainPageInfo.AuthorAvatarImageSource = authorAvatarImageSource.Value;
            }
            var authorGreetingText = repository.GetSiteProperty("AuthorGreetingText");
            if (authorGreetingText != null)
            {
                MainPageInfo.AuthorGreetingText = authorGreetingText.Value;
            }

            if (Content.ContentType == 2)
            {
                Articles = GetAllArticles(repository, langId);
            }

            LastArticles = GetLastArticles(repository, langId, int.Parse(SiteSettings.GetShopSetting("ArticlesQuantity")));
            QuickAdvices = repository.GetQuickAdvices(true);

            if (articleName != null)
            {
                this.Article = repository.GetArticle(articleName);
            }
           
        }