public ActionResult Index(string search = "", int catid = 0) { List <Model.MContent> articleList = LContent.GetRandomArticles(10, 0); categoryId = catid; searchStr = search; pageIndex = 0; aList.Clear(); var list = (from l in articleList where l.Conten.Contains("<img src=") orderby Guid.NewGuid() select l).Take(6).ToList(); List <ViewModels.VMArticle> vList = GetVmList(list); ViewData["ShowList"] = vList; //首页图片轮播 var ywList = (from l in articleList where l.Conten.Contains("<img src=") orderby l.ReleaseTime descending select l).Take(4).ToList(); List <ViewModels.VMArticle> vywList = GetVmList(ywList); ViewData["NewList"] = vywList; //最新要闻 decimal total = LContent.GetArticleTotal(); int pcount = Convert.ToInt32(Math.Ceiling(total / 10)); //页数 ViewBag.PageCount = pcount; ViewBag.Search = search; ViewBag.CatID = catid; ViewModels.VMUser vUser = Session["LoginUser"] as ViewModels.VMUser; //获取session ViewBag.IsLogin = vUser == null; ViewBag.Name = vUser == null ? "" : vUser.UserName; ViewBag.VCount = LVisitorCount.GetVisitorCount().Count; if (State) { return(View("MobileIndex")); } return(View()); }
public ActionResult FavoritesList(string search = "") { List <ViewModels.VMFavorites> vList = new List <ViewModels.VMFavorites>(); ViewBag.Name = string.Empty; ViewBag.IsLogin = false; ViewBag.Search = search; if (Session["LoginUser"] is ViewModels.VMUser vUser) { var list = string.IsNullOrEmpty(search) ? LFavorites.GetFavorites(vUser.UID) : LFavorites.SearchFav(search, vUser.UID); foreach (var item in list) { ViewModels.VMFavorites vModel = new ViewModels.VMFavorites { FaID = item.FaID, ArticleID = item.ArticleID, FavoritesTime = item.FavoritesTime.ToShortDateString(), FaTitle = item.FaTitle }; vList.Add(vModel); } ViewBag.Name = vUser.UserName; ViewBag.IsLogin = true; } ViewBag.VCount = LVisitorCount.GetVisitorCount().Count; if (State) { return(View("MobileFavoritesList", vList)); } return(View(vList)); }
public ActionResult ArticleInfo(long inArticleID) { Model.MContent model = LContent.GetArticle(inArticleID); ViewModels.VMArticle vModel = new ViewModels.VMArticle(); if (model != null) { vModel.ArticleID = model.ArticleID; vModel.Title = model.Title; vModel.DomainID = model.DomainID; vModel.ReleaseTime = ConvertLongToDateTime(model.ReleaseTime).ToShortDateString(); vModel.Conten = model.Conten; ViewBag.IsLogin = false; ViewBag.Name = string.Empty; ViewBag.CatName = GetCatName(vModel.DomainID); ViewBag.VCount = LVisitorCount.GetVisitorCount().Count; //获取session,判断是否为空 if (Session["LoginUser"] is ViewModels.VMUser vUser) { vModel.IsFavorites = LFavorites.ExistFavorites(vModel.ArticleID, vUser.UID); Model.MFootmarks footmarks = new Model.MFootmarks { UID = vUser.UID, ArticleID = vModel.ArticleID, MarkTime = DateTime.Now, FmTitle = vModel.Title }; string fmID = LFootmarks.ExistFootmark(vUser.UID, vModel.ArticleID); if (string.IsNullOrEmpty(fmID)) { LFootmarks.CreateFootmark(footmarks); } else { footmarks.FmID = Convert.ToInt32(fmID); LFootmarks.UpdateFootmark(footmarks); } ViewBag.IsLogin = true; ViewBag.Name = vUser.UserName; } } #region 推荐文章&商品 var raList = LContent.GetRandomArticles(3, vModel.DomainID); List <ViewModels.VMArticle> vRaList = new List <ViewModels.VMArticle>(); foreach (var item in raList) { ViewModels.VMArticle ar = new ViewModels.VMArticle { ArticleID = item.ArticleID, Title = item.Title, DomainID = item.DomainID, ReleaseTime = ConvertLongToDateTime(item.ReleaseTime).ToShortDateString(), ImgSrc = GetSrc(item.Conten) }; vRaList.Add(ar); } ViewData["RelatedArticle"] = vRaList; ViewData["Items"] = TuiJian(vModel.Title); #endregion if (State) { return(View("MobileArticleInfo", vModel)); } return(View(vModel)); }