Exemplo n.º 1
0
        /// <summary>
        /// 图片展示
        /// </summary>
        /// <param name="id">专辑Id</param>
        public ActionResult Show(string id)
        {
            this.Internationalization();

            ImageModel model = new ImageModel();

            try
            {
                AlbumService albumService = new AlbumService();

                AlbumDetail albumDetail = albumService.GetAlbumDetail(Int32.Parse(id));

                if (albumDetail != null)
                {
                    model.Album = albumDetail.Album;
                    model.Category = albumDetail.Category;
                    model.Images = albumDetail.Images;
                    model.LastAlbum = albumDetail.LastAlbum;
                    model.NextAlbum = albumDetail.NextAlbum;
                    model.RelatedAlbum = albumDetail.RelatedAlbum;
                    model.RecommendAlbum = albumDetail.RecommendAlbum;
                }
            }
            catch (Exception e)
            {
                model = new ImageModel();
                model.Category = new Category();
                model.Album = new Album();
                model.Album.Title = e.Message;
                model.Album.Description = e.ToString();
            }

            model.Album = model.Album ?? new Album();
            model.Category = model.Category ?? new Category();
            //model.LastAlbum = model.LastAlbum ?? new Album();
            //model.NextAlbum = model.NextAlbum ?? new Album();
            model.RelatedAlbum = model.RelatedAlbum ?? new List<Album>();
            model.RecommendAlbum = model.RecommendAlbum ?? new List<Album>();

            return View(model);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 图片展示
        /// </summary>
        /// <param name="id">专辑Id</param>
        public ActionResult Show(string id, string page)
        {
            this.Internationalization();

            ImageModel model = new ImageModel();

            try
            {
                AlbumService albumService = new AlbumService();

                AlbumDetail albumDetail = albumService.GetAlbumDetail(Int32.Parse(id));

                if (albumDetail != null)
                {
                    int pageIndex = 1;
                    if (Int32.TryParse(page, out pageIndex))
                    {
                        model.Page = pageIndex;
                    }
                    else
                    {
                        model.Page = 1;
                    }
                    model.Album = albumDetail.Album;
                    model.Category = albumDetail.Category;
                    model.Images = albumDetail.Images;
                    model.Image = model.Images[model.Page - 1];
                    model.LastAlbum = albumDetail.LastAlbum;
                    model.NextAlbum = albumDetail.NextAlbum;
                    model.RelatedAlbum = albumDetail.RelatedAlbum;
                    model.RecommendAlbum = albumDetail.RecommendAlbum;
                    model.RelatedNews = new NewsService().GetRelatedNewsByAlbumId(model.Album.Id);
                }
            }
            catch (Exception e)
            {
                model = new ImageModel();
                model.Category = new Category();
                model.Album = new Album();
                model.Album.Title = e.Message;
                model.Album.Description = e.ToString();
            }

            model.Album = model.Album ?? new Album();
            model.Category = model.Category ?? new Category();
            //model.LastAlbum = model.LastAlbum ?? new Album();
            //model.NextAlbum = model.NextAlbum ?? new Album();
            model.RelatedAlbum = model.RelatedAlbum ?? new List<Album>();
            model.RecommendAlbum = model.RecommendAlbum ?? new List<Album>();

            return View(model);
        }