예제 #1
0
        // GET: MoviesTicket
        public ActionResult Index()
        {
            try {
                List <MoviePosters> moviesDescription = new List <MoviePosters>();

                List <Movy> movies = Getmovies();
                // Movy movy = entities.Movies.Where(id => id.MovieId == 1).FirstOrDefault();
                List <string> movielist = new List <string>();

                for (int i = 0; i < movies.Count; i++)
                {
                    string       movie        = string.Format("data:image/png;base64," + Convert.ToBase64String(movies[i].Poster, 0, movies[i].Poster.Length));
                    MoviePosters moviePosters = new MoviePosters(movies[i].MovieId, movie, movies[i].MovieName);
                    moviesDescription.Add(moviePosters);
                    movielist.Add(movie);
                }


                ViewBag.list = movies;
                if (Session["userId"] != null)
                {
                    return(View("UserIndex", movies));
                }

                return(View(movies));
            }
            catch (Exception ex) { throw ex; }
        }
예제 #2
0
        private static async Task <Poster> GetPoster(string filename)
        {
            try
            {
                BitmapImage image = await MoviePosters.GetMoviePosterAsync(filename);

                ImageFormat format = ImageUtility.GetImageFormat(filename);
                Uri         uri    = ImageUtility.PosterURLFromFilename(filename);

                return(new Poster(format, uri, filename, image));
            }
            catch (ServerException e)
            {
                throw e;
            }
            catch (FileNotFoundException e)
            {
                Uri         fileNotFoundUri = new Uri("pack://application:,,,/Images/file-not-found.jpg");
                BitmapImage image           = new BitmapImage(fileNotFoundUri);
                image.Freeze();
                return(new Poster(ImageFormat.Jpeg, fileNotFoundUri, "file-not-found.jpg", image));
            }
            catch (Exception e)
            {
                throw e;
            }
        }