using CZFW.Framework.Interface; using CZKJ.GBRS2.Interface; using CZKJ.GBRS2.WebMVC.Models; using Microsoft.AspNetCore.Mvc; using System.ComponentModel; using System.Linq; namespace CZKJ.GBRS2.WebMVC.Controllers { public class PublicInfoController : Controller { IPublicInfo _publicInfologic; IPublicType _publicTypeLogic; IGallery _galleryLogic; public PublicInfoController(IPublicInfo publicinfologic, IPublicType publicTypeLogic, IGallery galleryLogic) { _publicInfologic = publicinfologic; _publicTypeLogic = publicTypeLogic; _galleryLogic = galleryLogic; } public IActionResult Index(int? typeId, int? id, int pageIndex = 1, int pageSize = 10) { int rowsCount; var model = new PublicInfoIndexModel(); var entity = id.HasValue ? _publicInfologic.GetEntity(id.Value) : new Entity.PublicInfoEntity(); model.PublicInfoEntity = entity; model.GalleryEntity = _galleryLogic.GetEntity(x => x.TypeId == 132); typeId = typeId.HasValue ? typeId : entity.TypeId == 0 ? _publicTypeLogic.GetChildList(null)[0].Id : entity.TypeId; model.TypeId = typeId.Value; model.ArticleList = _publicInfologic.GetEntities(out rowsCount, x => x.TypeId == typeId, pageIndex, pageSize, x => x.SortOrder, ListSortDirection.Descending); var typeList = _publicTypeLogic.GetEntities(); model.TypeList = typeList; model.TypeName = typeList.FirstOrDefault(x => x.Id == typeId.Value).Name; model.RowsCount = rowsCount; model.PageIndex = pageIndex; model.Id = id; if (id.HasValue) { model.SeoTitle = entity.SeoTitle; model.SeoKeywords = entity.SeoKeywords; model.SeoDescription = entity.SeoDescription; model.ShareTitle = entity.ShareTitle; model.ShareUrl = entity.ShareUrl; model.ShareImage = entity.ShareImage; model.ShareDescription = entity.ShareDescription; } return View(model); } } }