Пример #1
0
        public ActionResult DanhSachNhomTin()
        {
            V308CMSEntities   mEntities        = new V308CMSEntities();
            NewsRepository    newsRepository   = new NewsRepository(mEntities);
            List <News>       mList            = null;
            List <NewsGroups> mListNhom        = null;
            string            str              = "";
            DanhSachNhomTin   mDanhSachNhomTin = new DanhSachNhomTin();
            NhomTin           mNhomTin         = null;

            try
            {
                //lay danh sach nhom tin
                mListNhom = newsRepository.LayDanhSachNhomTin();
                //lay danh sach cac tin theo nhom
                foreach (NewsGroups it in mListNhom)
                {
                    mNhomTin           = new NhomTin();
                    mNhomTin.ID        = it.ID;
                    mNhomTin.GroupName = it.Name;
                    mNhomTin.Order     = (int)it.Number;
                    //lay danh sach cac tin hot nhat theo nhom
                    mList             = newsRepository.LayDanhSachTinTheoGroupId(6, it.ID);
                    mNhomTin.NewsList = mList;
                    mDanhSachNhomTin.List.Add(mNhomTin);
                }
                str = V308HTMLHELPER.TaoDanhSachTinTrangChu(mDanhSachNhomTin);
                return(View((object)str));
            }
            catch (Exception ex)
            {
                return(Content("<dx></dx>"));
            }
            finally
            {
                mEntities.Dispose();
                newsRepository.Dispose();
            }
        }
Пример #2
0
        public override void KhoiTao(SqlConnection con)
        {
            StringBuilder sb = new StringBuilder();
            sb.AppendFormat(@"
            <div class=""box6"" style=""{0}"">
            <div class=""box-body"">", Css);
            sb.Append(@"<div class=""box-body-top"">");
            HttpContext c = HttpContext.Current;
            if (string.IsNullOrEmpty(Ma_Trang_Chu)) Ma_Trang_Chu = "6";
            if (Ma_Sub == null) Ma_Sub = "8";
            #region Tin mới nhất
            sb.Append(@"<div class=""newest-box"">");
            int i = 0;
            foreach (Tin item in TinDal.SelectTop(con, 7))
            {
                if (i == 0)
                {
                    sb.Append(TinDal.formatHeadNewestBig(item, domain));
                }
                else
                {
                    sb.Append(TinDal.formatHeadNewestTiny(item, domain));
                }
                i++;
            }
            sb.Append(@"</div>");
            #endregion
            #region Tin trang chu

            sb.Append(@"<div class=""headline-box"">");
            List<NhomTin> List = NhomTinDal.SelectByNhomId(con, Ma_Trang_Chu);
            NhomTin Item = new NhomTin();
            if (List.Count > 0)
            {
                Item = List[0];
                sb.Append(TinDal.formatHeadBig(Item._Tin, domain));
                foreach (NhomTin item in List)
                {
                    if (item.ID != Item.ID)
                    {
                        sb.Append(TinDal.formatHeadTiny(item._Tin, domain));
                    }
                }
            }
            sb.Append(@"</div>");
            #endregion
            sb.Append(@"</div>");
            sb.Append(@"<div class=""box-body-center"">");
            sb.Append(@"<div class=""box-body-center-r""></div>");
            sb.Append(@"<div class=""box-body-center-l""></div>");
            sb.Append(@"</div>");

            #region Tin bên dưới
            sb.Append(@"<div class=""box-body-bottom"">");
            sb.Append(@"<div class=""headline-subbox"">");
            List = NhomTinDal.SelectByNhomId(con, Ma_Sub).Take(4).ToList();
            foreach (NhomTin item in List)
            {
                sb.Append(TinDal.formatSubHeadTiny(item._Tin, domain));
            }
            sb.Append(@"</div>");
            sb.Append(@"</div>");
            #endregion

               sb.AppendFormat(@"
            </div>
            </div>");
               c.Session["Title"] = "KenhThongTin.vn";
               Html = sb.ToString();
            base.KhoiTao(con);
        }