/// <summary> /// 新闻首页 /// </summary> public ActionResult Index(string category, string page) { this.Internationalization(); NewsModel model = new NewsModel(); if (string.IsNullOrEmpty(page)) { page = "1"; } NewsService newsService = new NewsService(); model.Page = Int32.Parse(page); model.PageSize = 10;//每页显示10张 model.PageIndex = Int32.Parse(page); int count = 0; //新闻列表 if (string.Equals(category, "news", StringComparison.CurrentCultureIgnoreCase)) { category = null; } model.NewsList = newsService.GetNewsList(category, null, model.PageSize, model.PageIndex, out count); //分页 if (model.NewsList != null && model.NewsList.Count > 0) { model.PageStep = 10; //页码10个 model.AllCount = count; if (model.AllCount % model.PageSize == 0) { model.PageCount = model.AllCount / model.PageSize; } else { model.PageCount = model.AllCount / model.PageSize + 1; } } if (category == null || string.Equals(category, "news", StringComparison.CurrentCultureIgnoreCase)) { CategoryService categoryService = new CategoryService(); model.Category = categoryService.GetCategoryById(category ?? "news"); } else { WitBird.Sex.Model.NewsCategory newsCategory = newsService.GetNewsCategoryById(category); model.Category = new Model.Category(); model.Category.Id = newsCategory.Id; model.Category.Name = newsCategory.Name; model.Category.Description = newsCategory.Description; model.Category.Keywords = newsCategory.Keywords; } //VideoService videoService = new VideoService(); //猜你喜欢 //model.Like = videoService.GetLike(16); return View(model); }
/// <summary> /// 新闻首页 /// </summary> public ActionResult Index(string page) { this.Internationalization(); NewsModel model = new NewsModel(); if (string.IsNullOrEmpty(page)) { page = "1"; } NewsService newsService = new NewsService(); model.Page = Int32.Parse(page); model.PageSize = 10;//每页显示10张 model.PageIndex = Int32.Parse(page); int count = 0; //视频列表 model.NewsList = newsService.GetNewsList(null, null, model.PageSize, model.PageIndex, out count); //分页 if (model.NewsList != null && model.NewsList.Count > 0) { model.PageStep = 10; //页码10个 model.AllCount = count; if (model.AllCount % model.PageSize == 0) { model.PageCount = model.AllCount / model.PageSize; } else { model.PageCount = model.AllCount / model.PageSize + 1; } } CategoryService categoryService = new CategoryService(); model.Category = categoryService.GetCategoryById("news"); VideoService videoService = new VideoService(); //猜你喜欢 //model.Like = videoService.GetLike(16); return View(model); }
// // GET: /Search/ public ActionResult Index(string keywords, string page) { this.Internationalization(); SearchModel model = new SearchModel(); AlbumService albumService = new AlbumService(); NewsService newsService = new NewsService(); int tempPage = 1; if (!string.IsNullOrEmpty(page)) { Int32.TryParse(page, out tempPage); } //专辑列表 int tempCount = 0; int tempCount1 = 0; int pageSize = 20; model.NewsResult = newsService.GetNewsList(string.Empty, keywords, 6, tempPage, out tempCount); if (tempCount > 0 && model.NewsResult != null && model.NewsResult.Count > 6) { pageSize = 8; } model.AlbumResult = albumService.GetAlbumList(null, keywords, pageSize, tempPage, out tempCount1); model.TotalResultsCount = tempCount + tempCount1; model.TotalNewsCount = tempCount; model.TotalAlbumCount = tempCount1; if (tempCount1 == 0 && tempCount < 10) { model.RecommendAlbum = albumService.GetRecommendRandom(20); } tempCount = tempCount1 > tempCount ? tempCount1 : tempCount; //分页 if ((model.AlbumResult != null && model.AlbumResult.Count > 0) || (model.NewsResult != null && model.NewsResult.Count > 0)) { model.PageIndex = tempPage; model.PageSize = pageSize; model.PageStep = 10; model.AllCount = tempCount; if (model.AllCount % model.PageSize == 0) { model.PageCount = model.AllCount / model.PageSize; } else { model.PageCount = model.AllCount / model.PageSize + 1; } } //关键字 model.Keywords = keywords; if (model.AlbumResult == null) { model.AlbumResult = new List<Album>(); } return View(model); }
public ActionResult Index(string categoryId, string keywords, string page) { if (Session["UserId"] == null) { return Redirect("/admin/login"); } NewsService newsService = new NewsService(); int tempPage = 1; if (!string.IsNullOrEmpty(page)) { Int32.TryParse(page, out tempPage); } NewsModel model = new NewsModel(); //新闻类别列表 model.NewsCategories = newsService.GetNewsCategories(); //当前选中新闻类别 model.NewsCategory = new NewsCategory(); if (!string.IsNullOrEmpty(categoryId)) { if (model.NewsCategories != null && model.NewsCategories.Count > 0) { foreach (var item in model.NewsCategories) { if (item.Id == categoryId) { model.NewsCategory = item; break; } } } } //新闻列表 int tempCount = 0; model.NewsList = newsService.GetNewsList(categoryId, keywords, 15, tempPage, out tempCount); //分页 if (model.NewsList != null && model.NewsList.Count > 0) { model.PageIndex = tempPage; model.PageSize = 15; model.PageStep = 10; model.AllCount = tempCount; if (model.AllCount % model.PageSize == 0) { model.PageCount = model.AllCount / model.PageSize; } else { model.PageCount = model.AllCount / model.PageSize + 1; } } //关键字 model.Keywords = keywords; return View(model); }