Example #1
0
        /// <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);
        }