using Microsoft.AspNetCore.Mvc; using CZFW.Framework.Interface; using CZKJ.GBRS2.Interface; using CZKJ.GBRS2.WebMVC.Models; using System.Linq; using CZFW.Framework.Model.Entity; using CZFW.Framework.Model.Enum; using System.ComponentModel; using System.Collections.Generic; namespace CZKJ.GBRS2.WebMVC.Controllers { public class HomeController : Controller { IGallery _galleryLogic; IType _typeLogic; IArticle _articleLogic; IFiles _fileLogic; INavigation _navigationLogic; IProduct _productLogic; ISysConfig _sysConfigLogic; public HomeController(IGallery galleryLogic, IType typeLogic, IArticle articleLogic, IFiles fileLogic, INavigation navigationLogic, IProduct productLogic,ISysConfig sysConfigLogic) { _galleryLogic = galleryLogic; _typeLogic = typeLogic; _articleLogic = articleLogic; _fileLogic = fileLogic; _navigationLogic = navigationLogic; _productLogic = productLogic; _sysConfigLogic = sysConfigLogic; } public IActionResult Index() { var model = new IndexModel(); var idList = new List { 107, 108, 109, 148, 128,150 }; var galleryList = _galleryLogic.GetGalleryList(idList); model.GalleryList = galleryList.Where(x => x.TypeId == 107).ToList(); model.ProductList = galleryList.Where(x => x.TypeId == 128).ToList(); model.FastIConList = galleryList.Where(x => x.TypeId == 109).ToList(); model.BackGalleryList = galleryList.Where(x => x.TypeId == 150).ToList(); model.LeftServicegallery = galleryList.FirstOrDefault(x => x.TypeId == 108) ?? new GalleryEntity(); var typeList = _typeLogic.GetEntities(x => x.ParentId == (int)DefaultDataEnum.NewsCenterParentId, x => x.SortOrder, ListSortDirection.Descending).Take(4).ToList(); model.TypeList = typeList; var typeIdList = typeList.Select(x => x.Id).ToList(); model.ChildrenList = _typeLogic.GetEntities(x => typeIdList.Contains(x.ParentId)); model.ServiceList = galleryList.Where(x => x.TypeId == 148).ToList(); var configList = _sysConfigLogic.GetSysConfig("Twitter", "Facebook", "Weibo", "WeChatCode"); model.Wechat = configList.First(x => x.Key == "WeChatCode").Value; model.Weibo = configList.First(x => x.Key == "Weibo").Value; model.Facebook = configList.First(x => x.Key == "Facebook").Value; model.Twitter = configList.First(x => x.Key == "Twitter").Value; return View(model); } public IActionResult AboutUs() { var model = new AboutUsModel(); //依次为:顶部广告位 企业愿景广告位(大事记 法律声明 分支机构) 分支机构 (领导讲话 党建工作)股东背景广告位集合 IList idList = new List { 136, 137, 138, 139, 140, 141 }; var galleryList = _galleryLogic.GetEntities(x => idList.Contains(x.TypeId), x => x.SortOrder, ListSortDirection.Descending); model.Summary = _articleLogic.GetEntity(52); model.TopGallery = galleryList.FirstOrDefault(x => x.TypeId == 136); model.EnterpriseVision = galleryList.FirstOrDefault(x => x.TypeId == 137); model.CenterGalleryList = galleryList.Where(x => x.TypeId == 138).ToList(); model.Department = galleryList.FirstOrDefault(x => x.TypeId == 139); model.LastGalleryList = galleryList.Where(x => x.TypeId == 140).ToList(); model.BackgroundList = galleryList.Where(x => x.TypeId == 141).ToList(); return View(model); } /// /// 资料下载 /// /// /// /// public IActionResult Download(int pageIndex = 1, int pageSize = 10) { int rowsCount; var list = _fileLogic.GetEntities(out rowsCount, null, pageIndex, pageSize, x=>x.SortOrder, ListSortDirection.Descending); ViewBag.RowsCount = rowsCount; ViewBag.PageIndex = pageIndex; return View(list); } public IActionResult Map() { return View(_navigationLogic.GetNavigationTreeByMark("0$15231983314041342$")); } public IActionResult Search(string keywords, int aPageIndex = 1, int aPageSize = 10, int pPageIndex = 1, int pPageSize = 10) { var model = new HomeSearchModel(); int aRowsCount; int pRowsCount; model.ArticleList = _articleLogic.GetSearchResult(keywords, aPageIndex, aPageSize, out aRowsCount); model.ProductList = _productLogic.GetSearchResult(keywords, pPageIndex, pPageSize, out pRowsCount); model.aPageIndex = aPageIndex; model.aRowsCount = aRowsCount; model.pPageIndex = pPageIndex; model.pRowsCount = pRowsCount; model.Keywords = keywords; return View(model); } } }