예제 #1
0
        public static NewsListModel BuildNews(DASEntities db)
        {
            NewsListModel model = new NewsListModel();


            int languageId = (int)HttpContext.Current.Session["lngId"];

            model.NewsList = db.News.Where(l => l.LanguageId == languageId && l.Archive == false).Select(n => new NewsModel()
            {
                NewsId = n.NewsId, Name = n.Name, Text = n.Text, Year = n.Year, Ord = n.Ord, Archive = n.Archive, LanguageId = n.LanguageId
            }).OrderByDescending(l => l.Year).ThenByDescending(l => l.Ord).ToList();

            IList <int> pomArch = db.News.Include("Archive").Where(l => l.LanguageId == languageId && l.Archive == true).Select(k => k.Archives.FirstOrDefault().ArchiveId).Distinct().ToList();

            string archiveLbl = LabelCache.GetLabel("Home", "lblArchive");
            string newsLbl    = LabelCache.GetLabel("Home", "lblNovosti");

            var list = db.Archives.OrderByDescending(l => l.Year).ToList();

            model.ArchiveList = new List <ArchiveModel>();
            foreach (var item in pomArch)
            {
                Archive temp = list.OrderByDescending(m => m.Year).FirstOrDefault(b => b.ArchiveId == item);
                model.ArchiveList.Add(new ArchiveModel()
                {
                    ArchiveId = temp.ArchiveId, Name = archiveLbl + " " + temp.Year
                });
            }

            model.ArchiveList.Add(new ArchiveModel()
            {
                ArchiveId = 0, Name = newsLbl
            });
            model.ArchiveList       = model.ArchiveList.OrderByDescending(m => m.ArchiveId).ToList();
            model.SelectedArchiveId = 0;

            return(model);
        }
예제 #2
0
 public void ShouldCacheIsReset()
 {
     LabelCache.GetLabel("Red").Should().Be(null);
 }
예제 #3
0
 public static string INIGroupLabel(string viewId, string elementId)
 {
     return(LabelCache.GetLabel(viewId, elementId));
 }
예제 #4
0
 // TODO: label extractor
 public static string INIGroupLabel(this HtmlHelper helper, string viewId, string elementId)
 {
     return(LabelCache.GetLabel(viewId, elementId));
 }