Пример #1
0
        public async Task <ActionResult> ListSectionInfo(int id)
        {
            Tuple <List <Information>, List <Section>, int> model = null;
            List <Information> infolost = null;
            NewsModel          news     = await _context.NewsModel.Include(r => r.ListSections).FirstOrDefaultAsync(r => r.Id == id);

            if (news != null)
            {
                infolost = new List <Information>();
                for (int i = 0; i < news.ListSections.Count; i++)
                {
                    LoadInformation(infolost, news.ListSections[i]);
                    if (news.ListSections[i].Disciples.Count != 0)
                    {
                        infolost.AddRange(news.ListSections[i].Disciples);
                    }
                }
            }

            for (int i = 0; i < infolost.Count; i++)
            {
                infolost[i].Info = HtmlClear.ClearHtml(infolost[i].Info);
                if (!string.IsNullOrEmpty(infolost[i].Info) && infolost[i].Info.Length > LengthInfo)
                {
                    infolost[i].Info = infolost[i].Info.Substring(0, LengthInfo) + "...";
                }
            }

            model = new Tuple <List <Information>, List <Section>, int>(infolost, news?.ListSections, id);

            return(View(model));
        }
Пример #2
0
        public async Task <ActionResult> AddNewLents(int id)
        {
            Tuple <List <Information>, int> model = null;
            List <Information> list = null;

            list = await _context.Information.Where(r => r.ButtonId == id && r.Cat == "ListModel").ToListAsync();

            if (list != null)
            {
                for (int i = 0; i < list.Count; i++)
                {
                    list[i].Info = HtmlClear.ClearHtml(list[i].Info);
                    if (!string.IsNullOrEmpty(list[i].Info) && list[i].Info.Length > LengthInfo)
                    {
                        list[i].Info = list[i].Info.Substring(0, LengthInfo) + "...";
                    }
                }
            }

            model = new Tuple <List <Information>, int>(list, id);

            return(View(model));
        }