Exemple #1
0
        public ActionResult Show(string id)
        {
            this.Internationalization();

            NewsModel model = new NewsModel();

            if (string.IsNullOrEmpty(id))
            {
                id = "1";
            }

            NewsService newsService = new NewsService();
            model.News = newsService.GetNewsById(Int32.Parse(id));

            //随机推荐
            //model.RecommendRandoms = newsService.GetRecommendRandom(6);

            //猜你喜欢
            //VideoService videoService = new VideoService();
            //model.Like = videoService.GetLike(16);

            //推荐新闻
            //model.RecommendNews = NewsService.GetRecommendRandom(10);

            //推荐小说
            //model.RecommendNovels = NovelService.GetRecommendRandom(10);

            if (model.News == null)
            {
                model.News = new Model.News();
                model.News.Title = "该新闻不存在或已被删除";
            }
            else
            {
                AlbumService albumService = new AlbumService();
                int outCount = 0;
                model.RelatedAlbum = albumService.GetAlbumList(string.Empty, model.News.Keywords, 8, 1, out outCount);
                model.RelatedNews = newsService.GetRelatedNews(model.News.Id);
            }

            return View(model);
        }
Exemple #2
0
        //
        // 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);
        }
Exemple #3
0
        public ActionResult Show(string id)
        {
            this.Internationalization();

            NewsModel model = new NewsModel();

            if (string.IsNullOrEmpty(id))
            {
                id = "1";
            }

            NewsService newsService = new NewsService();
            model.News = newsService.GetNewsById(Int32.Parse(id));

            if (model.News == null)
            {
                model.News = new Model.News();
                model.News.Title = "该新闻不存在或已被删除";
            }
            else
            {
                AlbumService albumService = new AlbumService();
                int outCount = 0;
                model.RelatedAlbum = albumService.GetAlbumList(string.Empty, model.News.Keywords, 5, 1, out outCount);
                model.RelatedNews = newsService.GetRelatedNews(model.News.Id);
                model.LastNews = newsService.GetPrvNewsById(model.News.Id);
                model.NextNews = newsService.GetNextNewsById(model.News.Id);
            }

            return View(model);
        }
Exemple #4
0
        public ActionResult Index(string categoryId, string keywords, string page)
        {
            if (Session["UserId"] == null)
            {
                return Redirect("/admin/login");
            }

            AlbumService newsService = new AlbumService();

            int tempPage = 1;

            if (!string.IsNullOrEmpty(page))
            {
                Int32.TryParse(page, out tempPage);
            }

            ImagesModel model = new ImagesModel();

            //专辑类别列表
            model.Categories = categoryService.GetCategories("album");

            //当前选中专辑类别
            model.Category = new Category();
            if (!string.IsNullOrEmpty(categoryId))
            {
                if (model.Categories != null && model.Categories.Count > 0)
                {
                    foreach (var item in model.Categories)
                    {
                        if (item.Id == categoryId)
                        {
                            model.Category = item;
                        }
                    }
                }
            }

            //专辑列表
            int tempCount = 0;
            model.AlbumList = newsService.GetAlbumList(categoryId, keywords, 15, tempPage, out tempCount);
            //分页
            if (model.AlbumList != null && model.AlbumList.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);
        }