public ActionResult Index() { Sql sql1 = new Sql().Append( " WHERE DataType = @0 And IsMyStates=1 And IsAdminStates=1 And IsDefault=1 ", " Z001 ").OrderBy( " Sequence desc "); IList<NewsInfo> list1 = NewsService.GetList(sql1, 6); Sql sql2 = new Sql().Append( " WHERE DataType = @0 And IsMyStates=1 And IsAdminStates=1 And IsDefault=1 ", " Z002 ").OrderBy( " Sequence desc "); IList<NewsInfo> list2 = NewsService.GetList(sql2, 5); Sql sql3 = new Sql().Append( " WHERE DataType = @0 And IsMyStates=1 And IsAdminStates=1 And IsDefault=1 ", " Z003 ").OrderBy( " Sequence desc "); IList<NewsInfo> list3 = NewsService.GetList(sql3, 6); Sql sql4 = new Sql().Append( " WHERE DataType = @0 And IsMyStates=1 And IsAdminStates=1 And IsDefault=1 ", " Z004 ").OrderBy( " Sequence desc "); IList<NewsInfo> list4 = NewsService.GetList(sql4, 6); Sql sql5 = new Sql().Append( " WHERE DataType = @0 And IsMyStates=1 And IsAdminStates=1 And IsDefault=1 ", " Z005 ").OrderBy( " Sequence desc "); IList<NewsInfo> list5 = NewsService.GetList(sql5, 6); Sql sql6 = new Sql().Append( " WHERE DataType = @0 And IsMyStates=1 And IsAdminStates=1 And IsDefault=1 ", " Z006 ").OrderBy( " Sequence desc "); IList<NewsInfo> list6 = NewsService.GetList(sql6, 6); Sql sql7 = new Sql().Append( " WHERE DataType = @0 And IsMyStates=1 And IsAdminStates=1 And IsDefault=1 ", " Z007 ").OrderBy( " Sequence desc "); IList<NewsInfo> list7 = NewsService.GetList(sql7, 4); Sql sql8 = new Sql().Append( " WHERE DataType = @0 And IsMyStates=1 And IsAdminStates=1 And IsDefault=1 ", " Z008 ").OrderBy( " Sequence desc "); IList<NewsInfo> list8 = NewsService.GetList(sql8, 2); // IList<ConstDataInfo> list9 = ConstDataService.GetConstDataListLeafByType("C0001"); // IList<ConstDataInfo> list10 = ConstDataService.GetConstDataListLeafByType("C0002"); // IList<ConstDataInfo> list11 = ConstDataService.GetConstDataListLeafByType("C0003"); ViewBag.jList = ConstDataService.GetConstDataListRootByType(EnumUtil.ConstDataType.JfjcType); return View( new IndexModel(list1, list2, list3, list4, list5, list6, list7, list8)); }
model:
public class IndexModel
{
public IList<NewsInfo> list1 { get; private set; }
public IList<NewsInfo> list2 { get; private set; }
public IList<NewsInfo> list3 { get; private set; }
public IList<NewsInfo> list4 { get; private set; }
public IList<NewsInfo> list5 { get; private set; }
public IList<NewsInfo> list6 { get; private set; }
public IList<NewsInfo> list7 { get; private set; }
public IList<NewsInfo> list8 { get; private set; }
public IndexModel(IList<NewsInfo> s1, IList<NewsInfo> s2, IList<NewsInfo> s3, IList<NewsInfo> s4, IList<NewsInfo> s5, IList<NewsInfo> s6, IList<NewsInfo> s7, IList<NewsInfo> s8)
{
this.list1 = s1;
this.list2 = s2;
this.list3 = s3;
this.list4 = s4;
this.list5 = s5;
this.list6 = s6;
this.list7 = s7;
this.list8 = s8;
}
}
前台html
<div class="zhongxia">
@foreach (var item2 in Model.list2)
{
<div class="zhongxiain">
<div class="liebiao">
<a href="/News/Index/@item2.ID ">@MSP.Utility.WebUtilityHelper.GetCutString(item2.DataTitle, 22)
</a>
</div>
<div class="riqi">
<a href="/News/Index/@item2.ID ">@MSP.Utility.WebUtilityHelper.GetDateString(item2.CreateTime)
</a>
</div>
</div>
}
</div>