コード例 #1
0
        public MovieEntityModel PrepareMovieModel(MovieItem x, int picturesize = 400,
                                                  bool includeShortDesc        = true, bool includeDesc = false)
        {
            var model = x.ToModel();

            try
            {
                var mc       = _movieCategoryService.GetMovieCategoriesById(x.Id).FirstOrDefault(); //
                var category = mc.Category;
                model.HasEpisode = category.HasEpisodes;
                if (model.HasEpisode)
                {
                    var episodes = _subMovieService.GetAllMovieEpisodes(x.Id);
                    if (episodes != null && episodes.Any())
                    {
                        model.LastEpisode = episodes.LastOrDefault().Name.Split(' ')[1];
                    }
                }
                model.Description = includeDesc ? x.Description : "";
                if (includeShortDesc)
                {
                    var words = x.Description.Split(' ');
                    model.ShortDesc = string.Join(" ", words.Take(40));
                }
                model.Trailer = !String.IsNullOrWhiteSpace(model.Trailer) ? model.Trailer.Replace("watch?v=", "embed/") : "";
                var moviePictureCacheKey = string.Format(ModelCacheEventConsumer.MOVIE_PICTURE_PATTERN_KEY, x.Id, picturesize);
                model.Picture = _cacheManager.Get(moviePictureCacheKey, () =>
                {
                    var picture = _pictureService.GetPictureById(x.PictureId);
                    return(new PictureModel
                    {
                        FullSizeImageUrl = _pictureService.GetPictureUrl(picture),
                        ImageUrl = _pictureService.GetPictureUrl(picture, picturesize)
                    });
                });
            }
            catch (Exception e)
            {
            }

            return(model);
        }
コード例 #2
0
ファイル: MovieController.cs プロジェクト: vikhalv/butv
 private IList <SubMovieItemModel> LoadMovieEpisodes(int movieId)
 {
     return(_subMovieService.GetAllMovieEpisodes(movieId).Select(x => x.ToModel()).ToList());
 }