コード例 #1
0
        public async Task SaveMetadataOKTest()
        {
            var metaData = new MovieDetails
            {
                MoveId      = 3,
                Title       = "Elysium",
                Language    = "EN",
                Duration    = "1:49:00",
                ReleaseYear = 2013
            };

            string jsonMetadata = JsonConvert.SerializeObject(metaData);

            var logger         = Mock.Of <ILogger <MoviesController> >();
            var mockRepository = new Mock <IMovieRepository>();

            var expectedMovieId = 99;

            mockRepository.Setup(x => x.Save(jsonMetadata)).ReturnsAsync(expectedMovieId);

            var controller = new MoviesController(logger, mockRepository.Object);

            var result = await controller.SaveMetadata(jsonMetadata);

            var okResult    = Assert.IsType <OkObjectResult>(result);
            var returnValue = Assert.IsType <int>(okResult.Value);

            Assert.Equal(expectedMovieId, returnValue);
        }
コード例 #2
0
        public async Task <IActionResult> Edit(int id, [Bind("TrackNumber,Rating,Availability,Views")] MovieDetails movieDetails)
        {
            if (id != movieDetails.TrackNumber)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    Movielibrarian.UpdateMovieDetails(movieDetails);
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!MovieDetailsExists(movieDetails.TrackNumber))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(movieDetails));
        }
コード例 #3
0
        private void _onSelectedMovie(int row)
        {
            MovieDetails movie = this._movieList[row];

            NavigationItem.BackBarButtonItem = new UIBarButtonItem("Movie list", UIBarButtonItemStyle.Plain, null);
            this.NavigationController.PushViewController(new MovieDetailController(movie, this._api), true);
        }
コード例 #4
0
ファイル: TellMeAboutDialog.cs プロジェクト: mormond/WhoWasIn
        private async Task createCard(IDialogContext ctx, MovieDetails details)
        {
            List <Attachment> attachmentList = new List <Attachment>();

            CardImage        image  = new CardImage(details.poster_path);
            List <CardImage> images = new List <CardImage>()
            {
                image
            };

            ThumbnailCard h = new ThumbnailCard()
            {
                Title    = details.title,
                Subtitle = string.IsNullOrEmpty(details.release_date) ? "" : details.release_date.Substring(0, 4),
                //Tap = new CardAction(ActionTypes.OpenUrl, "Visit in IMDB", value: string.Format("http://www.imdb.com/title/{0}", x)),
                Text   = details.overview_short,
                Images = images,
                //Buttons = new List<CardAction>() { new CardAction(ActionTypes.OpenUrl, "Learn more", value: string.Format("http://www.imdb.com/title/{0}", x)) }
            };

            attachmentList.Add(h.ToAttachment());

            var reply = ctx.MakeMessage();

            reply.AttachmentLayout = AttachmentLayoutTypes.Carousel;
            reply.Attachments      = attachmentList;
            await ctx.PostAsync(reply);
        }
コード例 #5
0
        public async Task UpdateMovie(MovieDetails movie)
        {
            var employeeJson =
                new StringContent(JsonSerializer.Serialize(movie), Encoding.UTF8, "application/json");

            await _httpClient.PutAsync("api/employee", employeeJson);
        }
コード例 #6
0
        public void ConvertMovieWithVideosToMovieDetails_WithYoutubeTeaser_ReturnsValidDetails()
        {
            TheMovieDbApiOptions options = new TheMovieDbApiOptions()
            {
                YoutubeEmbed = "<iframe src=\"youtube.com/{video-id}\"/>"
            };
            var optionsMonitorMock = new Mock <IOptionsMonitor <TheMovieDbApiOptions> >();

            optionsMonitorMock.Setup(x => x.CurrentValue).Returns(options);
            var converter = new TheMovieDbConverter(optionsMonitorMock.Object);

            MovieWithVideosInfo movieWithVideosInfo = new MovieWithVideosInfo()
            {
                Videos = new ListData <VideoInfo>()
                {
                    Result = new System.Collections.Generic.List <VideoInfo>()
                    {
                        new VideoInfo()
                        {
                            Site = "YouTube",
                            Key  = "qwerty",
                            Type = "Teaser"
                        }
                    }
                }
            };
            MovieDetails movieDetails = new MovieDetails()
            {
                Teaser = "<iframe src=\"youtube.com/qwerty\"/>"
            };
            var result = converter.ConvertMovieWithVideosToMovieDetails(movieWithVideosInfo);

            Assert.AreEqual(movieDetails.Teaser, result.Teaser);
        }
コード例 #7
0
        public object getMoviesList()
        {
            try
            {
                MovieOperationsDAL  mo_dal          = new MovieOperationsDAL();
                DataTable           dtMovieDetails  = new DataTable();
                List <MovieDetails> lstMovieDetails = new List <MovieDetails>();
                dtMovieDetails = mo_dal.GetMoviesList();
                for (int i = 0; i < dtMovieDetails.Rows.Count; i++)
                {
                    MovieDetails md = new MovieDetails();
                    md.Name     = dtMovieDetails.Rows[i]["Name"].ToString();
                    md.Year     = dtMovieDetails.Rows[i]["Year"].ToString();
                    md.Actors   = dtMovieDetails.Rows[i]["Actors"].ToString();
                    md.Producer = dtMovieDetails.Rows[i]["Producer"].ToString();
                    md.Poster   = String.Format("<div align=center><img src='{0}' width='50' vspace='5'></div>", dtMovieDetails.Rows[i]["Poster"].ToString());
                    md.Actions  = dtMovieDetails.Rows[i]["Actions"].ToString();
                    lstMovieDetails.Add(md);
                }

                return(new { Message = "Success", MovieList = lstMovieDetails });
            }
            catch (Exception ex)
            {
                string error = " API - getmovieslist " + ex.Message;
                return(new { Message = "error", MessageReason = "There was some problem loading data. Please refresh try again! <br>" + error });
            }
        }
コード例 #8
0
        public List <MovieDetails> GetMovieDetails()
        {
            List <MovieDetails> MovieLists = new List <MovieDetails>();
            MovieDetails        MovieList  = new MovieDetails();
            SqlConnection       con        = null;

            try
            {
                con = new SqlConnection("data source=.; database=MovieReview; integrated security=SSPI");
                con.Open();
                SqlCommand    com = new SqlCommand("select * from Movies;", con);
                SqlDataReader dr  = com.ExecuteReader();
                while (dr.Read())
                {
                    MovieList           = new MovieDetails();
                    MovieList.MovieName = (string)dr["MoviewName"];
                    MovieList.MovieId   = (int)dr["MoviewId"];
                    MovieLists.Add(MovieList);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("something error", ex);
            }
            return(MovieLists);
        }
コード例 #9
0
        public MovieDetails ConvertMovieWithVideosToMovieDetails(MovieWithVideosInfo movie)
        {
            if (movie == null)
            {
                return(null);
            }

            var result = new MovieDetails();

            result.General  = ConvertMovieListItemToQuickInfo(movie);
            result.Budget   = movie.Budget;
            result.Revenue  = movie.Revenue;
            result.Website  = movie.Homepage;
            result.ImdbLink = "https://www.imdb.com/title/" + movie.ImdbId;
            var duration = TimeSpan.FromMinutes(movie.Runtime);

            result.Duration = duration.ToString();
            string teaserEmbed = null;

            if (movie.Videos != null && movie.Videos.Result != null)
            {
                var video = movie.Videos.Result.Where(x => x.Type.ToLower() == "teaser").FirstOrDefault();
                if (video != null && video.Site.ToLower() == "youtube")
                {
                    teaserEmbed = movieDbOptions.YoutubeEmbed.Replace("{video-id}", video.Key);
                }
            }
            result.Teaser = teaserEmbed;
            return(result);
        }
コード例 #10
0
        private async void LoadLatestMovies(MovieDetails movie = null)
        {
            if (movie == null)
            {
                IsBusy = true;
            }
            else
            {
                var currentIndex = MoviePageDetails?.Results?.IndexOf(movie) ?? 0;
                if (currentIndex == 0 || IsLoadingMore)
                {
                    return;
                }
                if (currentIndex + 5 < MoviePageDetails.Results.Count && MoviePageDetails.Results.Count != MoviePageDetails.TotalResults)
                {
                    return;
                }
                Console.WriteLine("====={0}", currentIndex);
                IsLoadingMore = true;
            }


            await Task.Delay(2000);

            var nextPage = movie == null ? 1 : MoviePageDetails.CurrentPage + 1;
            var response = await httpClient.GetStringAsync(MovieDetails.PopularUrl(nextPage));

            var moviePageDetails = JsonConvert.DeserializeObject <PageDetails <MovieDetails> >(response);

            UpdateMovieList(moviePageDetails);
            IsBusy = IsLoadingMore = false;
        }
コード例 #11
0
 public DetailsModel(WebDetailsService Service)
 {
     _service     = Service;
     Movie        = new Movie();
     MovieDetails = new MovieDetails();
     TVDetails    = new TVShowDetails();
 }
コード例 #12
0
        // GET: Filmis/Details/5
        public ActionResult Details(int?id)
        {
            try
            {
                if (id == null)
                {
                    return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
                }
                List <Filma_Salla> Fs = new List <Filma_Salla>();
                Fs = db.Filma_Salla.Where(x => x.Id_Filmi == id && x.Salla.Statusi == "Available").ToList();

                Filmi        F  = db.Filmis.Where(x => x.Id_Filmi == id).FirstOrDefault();
                MovieDetails MV = new MovieDetails();
                MV.filmi       = F;
                MV.filmi_salla = Fs;

                if (MV == null)
                {
                    return(HttpNotFound());
                }
                return(View(MV));
            }
            catch (Exception ex)
            {
                logger.ErrorException("Error u gjend ne Controller Filmi, Details Action", ex);
            }
            return(View());
        }
コード例 #13
0
ファイル: MovieService.cs プロジェクト: ronak111091/Project3
 public void GetMovieDetails(string id, MovieDetails movieDetails)
 {
     using (var client = new HttpClient())
     {
         string  url      = $"{baseUrl}{id}?{apiKeyValue}&language=en-US";
         var     response = client.GetAsync(url).Result;
         var     content  = response.Content.ReadAsStringAsync().Result;
         dynamic result   = Newtonsoft.Json.JsonConvert.DeserializeObject(content);
         movieDetails.backdrop_path = result.backdrop_path;
         movieDetails.budget        = result.budget;
         foreach (dynamic item in result.genres)
         {
             movieDetails.genres.Add((string)item.name);
         }
         movieDetails.homepage          = result.homepage;
         movieDetails.id                = result.id;
         movieDetails.imdb_link         = result.imdb_id;
         movieDetails.original_language = result.original_language;
         movieDetails.original_title    = result.original_title;
         movieDetails.overview          = result.overview;
         movieDetails.poster_path       = result.poster_path;
         foreach (dynamic item in result.production_companies)
         {
             movieDetails.production_companies.Add((string)item.name);
         }
         movieDetails.release_date = result.release_date;
         movieDetails.revenue      = result.revenue;
         movieDetails.runtime      = result.runtime;
         movieDetails.status       = result.status;
         movieDetails.title        = result.title;
         movieDetails.vote_average = result.vote_average;
     }
 }
コード例 #14
0
        public async Task <MovieDetails> GetMovieDetail(int id)
        {
            ApiQueryResponse <Movie> movieInfo = await _api.FindByIdAsync(id);

            MovieDetails movie = new MovieDetails();

            if (movieInfo.Item != null)
            {
                movie = new MovieDetails()
                {
                    title       = movieInfo.Item.Title,
                    runtime     = movieInfo.Item.Runtime.ToString(),
                    description = movieInfo.Item.Overview,
                    tagLine     = movieInfo.Item.Tagline,
                    budget      = movieInfo.Item.Budget,
                    genres      = new List <String>()
                };

                for (int i = 0; i < movieInfo.Item.Genres.Count; i++)
                {
                    movie.genres.Add(movieInfo.Item.Genres[i].ToString());
                }
            }
            return(movie);
        }
コード例 #15
0
        // To get price -> GetMovie(MP) return MovieDetails.Price (to sort dictionary make it a list first)

        private ModifiedMovieDetails GetModifyMovieDetail(MovieDetails md, List<Task<MovieDetails>> tasks)
        {

            // this is used to prevent repeating data (basiclly a  combination of two)
            if (md == null)
            {
                return new ModifiedMovieDetails();
            }

            var uniqueMoveDictionary = new Dictionary<MovieProviders, Movie>();

            ModifiedMovieDetails moveDetail = new ModifiedMovieDetails()
            {
                Title = md.Title,
                Year = md.Year,
                Rated = md.Rated,
                Released = md.Released,
                Runtime = md.Runtime,
                Genre = md.Genre,
                Director = md.Director,
                Writer = md.Writer,
                Actors = md.Actors,
                Plot = md.Plot,
                Language = md.Language,
                Country = md.Country,
                Awards = md.Awards,
                Poster = md.Poster,
                Metascore = md.Metascore,
                Rating = md.Rated,
                Votes = md.Votes,
                Prices = GetPricesOfMovieByProviders(tasks),
            };

                return moveDetail;
            }
コード例 #16
0
        public ActionResult BookMovie2(string Id)

        {
            //ViewBag.Movie = BooKMovieDetails();
            var chk = GetMovieDate(Id);

            ViewBag.Date = chk.Distinct().Select(i => new SelectListItem()
            {
                Text = i.AllDays.ToString(), Value = i.AllDays.ToString()
            }).ToList();
            var          outp = BooKMovieDetails();
            var          linq = outp.Where(x => x.MovieID == Id).Select(x => new { x.MovieID, x.MovieName }).ToList();
            MovieDetails obj  = new MovieDetails();

            foreach (var item in linq)
            {
                obj.MovieID   = item.MovieID;
                obj.MovieName = item.MovieName;
            }


            ViewBag.Classid   = DropDown.Classid();
            ViewBag.Showid    = DropDown.Showid();
            ViewBag.NoTickets = DropDown.NoTickets();
            return(PartialView("DeletePart", obj));
        }
コード例 #17
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Movie_Name,Movie_Description,DateToPresent,MoviePicture")] MovieDetails movieDetails)
        {
            if (id != movieDetails.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(movieDetails);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!MovieDetailsExists(movieDetails.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(movieDetails));
        }
コード例 #18
0
        //This method is called by the Create Action
        //Method calls the restful webservice hosted by the
        //open movie database.
        //Receives JSON with movie details, deserializes and populates the Create form.
        #region GetMovies
        public Movie AutoPopulateMovies(Movie movie)
        {
            MovieDetails MovieDetails = new MovieDetails();

            using (var client = new HttpClient())
            {
                //Populates the OMDB Url, along with the movie title added in the form, and ads the API key needed to call web service.
                //EscapeDataString method added to allow users to search names with special characters. example &
                var url        = Properties.Settings.Default.OMDBLink + Uri.EscapeDataString(movie.Title) + Properties.Settings.Default.APIKey;
                var webrequest = (HttpWebRequest)System.Net.WebRequest.Create(url);

                using (var response = webrequest.GetResponse())
                    using (var reader = new StreamReader(response.GetResponseStream()))
                    {
                        var result = reader.ReadToEnd();
                        //Deserializing the response recieved from web api and storing into the Movie list
                        JObject _jsonResponseObj = JObject.Parse(result);
                        try
                        {
                            MovieDetails = _jsonResponseObj.ToObject <MovieDetails>();
                        }
                        catch (Exception)
                        {
                            ModelState.AddModelError("Title", "Error retrieving movie from database. Make sure you enter a valid movie.");
                        }
                    }

                //Bind populated data to movie and return
                //Inplicit conversion was done in the Movie model
                movie = MovieDetails;
                return(movie);
            }
        }
コード例 #19
0
        public async Task <ActionResult <IEnumerable <MovieDetails> > > GetSummaryMovieDataById(int movieId)
        {
            Movie movie = await _context.Movies.FindAsync(movieId);

            if (movie == null)
            {
                return(NotFound());
            }
            Link link = await _context.Links.FindAsync(movieId);

            if (link == null)
            {
                return(NotFound());
            }

            if (link.ImdbPosterUrl == null)
            {
                string temp = await DataScraping.GetImdbMoviePosterUrlAsync(link.ImdbId);

                link.ImdbPosterUrl = (temp != null) ? temp : null;
            }

            MovieDetails movieDetails = new MovieDetails {
                Id = movie.Id, Title = movie.Title, Genres = movie.Genres, PosterUrl = link.ImdbPosterUrl
            };

            _context.Update(link);
            _context.SaveChanges(); // pentru salvarea link-uri postere

            return(Ok(movieDetails));
        }
コード例 #20
0
        /// <summary>
        /// This method is used to retrieve details of a movie
        /// </summary>
        /// <param name="configKey"></param>
        /// <param name="movieId"></param>
        /// <returns>MovieDetails</returns>
        #region GetMovieDetailsByMovieId
        private MovieDetails GetMovieDetailsByMovieId(string configKey, string movieId)
        {
            string       strResponseJSON = string.Empty;
            string       moviesListUrl   = string.Empty;
            string       requestData     = string.Empty;
            MovieDetails movieDetails    = new MovieDetails();

            try
            {
                moviesListUrl = System.Configuration.ConfigurationManager.AppSettings.Get(configKey);
                moviesListUrl = moviesListUrl + movieId + "/";

                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(moviesListUrl);
                request.Method = "GET";
                request.Headers.Add(System.Configuration.ConfigurationManager.AppSettings.Get("TokenKey"), System.Configuration.ConfigurationManager.AppSettings.Get("TokenValue"));
                request.ContentType = "application/json";
                HttpWebResponse response  = (HttpWebResponse)request.GetResponse();
                Stream          resStream = response.GetResponseStream();
                StreamReader    reader    = new StreamReader(resStream);
                strResponseJSON = reader.ReadToEnd();

                movieDetails = JsonConvert.DeserializeObject <MovieDetails>(strResponseJSON);
            }
            catch (Exception ex)
            {
                // Log the exception in either DB or using Log4net third party tool
            }

            return(movieDetails);
        }
コード例 #21
0
ファイル: TellMeAboutDialog.cs プロジェクト: mormond/WhoWasIn
        private async Task ShowDetails(IDialogContext ctx)
        {
            MovieDetails details = await GetMovieDetails(_entity);

            if (details != null)
            {
                IEnumerable <CastCredit> credits = await GetMovieCastCredits(details.id);

                credits = credits.OrderBy(x => x.order).Take(3);

                var starring = " starring ";
                foreach (var c in credits)
                {
                    starring += c.name;
                    starring += ", ";
                }

                starring = starring.Remove(starring.Length - 2);
                var idx = starring.LastIndexOf(",");
                if (idx >= 0)
                {
                    starring = starring.Substring(0, starring.Length - (starring.Length - idx)) + " and " + starring.Substring(idx + 2, starring.Length - idx - 2);
                }

                var message = details.title + " is a film released in " + details.release_date.Substring(0, 4) + starring;
                await ctx.PostAsync(message);
                await createCard(ctx, details);
            }
        }
コード例 #22
0
        //private bool _isRefreshing = false;

        public MovieListViewModel(INavigation navigation, List <MovieDetails> movieList)
        {
            this._service       = new MovieSearchService();
            this._navigation    = navigation;
            this._movieList     = movieList;
            this._selectedMovie = new MovieDetails();
        }
コード例 #23
0
        public async Task <MovieDetails> GetMovie(long id)
        {
            var          key   = String.Format("movie{0}", id);
            MovieDetails movie = _cacheService.Get <MovieDetails>(key);

            if (movie == null)
            {
                if (_connectivity.EnsureInternetAccess())
                {
                    var uri = ResourceIdentifier.MovieUri(id);
                    try
                    {
                        var responseString = await _httpService.Get(uri);

                        movie = (MovieDetails)_jsonConverter.DeserializeObject(responseString, typeof(MovieDetails));
                        _cacheService.Set(key, movie, CacheExpiry(15.0));
                    }
                    catch
                    {
                        ShowGetFailedNotification();
                        return(new MovieDetails());
                    }
                }
                else
                {
                    ShowConnectionNotification();
                    return(new MovieDetails());
                }
            }

            return(movie);
        }
コード例 #24
0
ファイル: MovieController.cs プロジェクト: Akarsh04/MovieSite
        // GET: Movie
        public ActionResult Index()
        {
            var displaymodel = new List <MovieViewModel>();
            var movieList    = _db.Movies.ToList();

            foreach (var movie in movieList)
            {
                var data = new MovieViewModel();

                data.ProducerName = _db.Producers.Find(movie.ProducerID).Name;

                var           ids        = _db.Actor_Movies.Where(s => s.MovieID == movie.Id).ToList();
                List <string> actorsName = new List <string>();

                foreach (var id in ids)
                {
                    actorsName.Add(_db.Actors.Find(id.ActorId).Name);
                }

                data.ActorsName = actorsName;
                data.Movie      = movie;

                displaymodel.Add(data);
            }

            var moviedatail = new MovieDetails();

            moviedatail.MovieData = displaymodel;



            return(View(moviedatail));
        }
コード例 #25
0
        public ProductDetails FindProduct(long id)
        {
            Product product;

            product = ProductDao.Find(id);
            long   categoryId   = product.categoryId;
            string categoryName = CategoryDao.Find(product.categoryId).name;

            ProductDetails productDetails;

            if (product is Movie)
            {
                Movie mov = product as Movie;
                productDetails = new MovieDetails(product.name, categoryId, categoryName, product.registerDate, product.prize, product.productId, product.numberOfUnits, false, mov.title, mov.director, mov.summary, mov.topic, mov.duration);
            }
            else if (product is Book)
            {
                Book book = product as Book;
                productDetails = new BookDetails(product.name, categoryId, categoryName, product.registerDate, product.prize, product.productId, product.numberOfUnits, false, book.title, book.author, book.summary, book.topic, book.pages);
            }
            else if (product is CD)
            {
                CD cd = product as CD;
                productDetails = new CDDetails(product.name, categoryId, categoryName, product.registerDate, product.prize, product.productId, product.numberOfUnits, false, cd.title, cd.artist, cd.topic, cd.songs);
            }
            else
            {
                productDetails = new ProductDetails(product.name, categoryId, categoryName, product.registerDate, product.prize, product.productId, product.numberOfUnits, false);
            }
            return(productDetails);
        }
コード例 #26
0
        public ActionResult GetOneMovie2(int id)
        {
            var db    = new DatabaseContext();
            var movie = db.Movies.FirstOrDefault(mo => mo.Id == id);

            if (movie == null)
            {
                return(NotFound());
            }
            else
            {
                // create our json object///////////////////
                var rv = new MovieDetails
                {
                    Id       = movie.Id,
                    Title    = movie.Title,
                    File     = movie.File,
                    Year     = movie.Year,
                    Genre    = movie.Genre,
                    Duration = movie.Duration,
                    Director = movie.Director,
                    Poster   = movie.Poster
                };
                return(Ok(rv));
            };
        }
コード例 #27
0
ファイル: MovieService.cs プロジェクト: jonhei13/Mapp
        private async Task <List <MovieDetails> > GetMovies(IReadOnlyList <MovieInfo> response)
        {
            var result = (from x in response select x).ToList();
            var Movies = new List <MovieDetails>();

            foreach (MovieInfo info in result)
            {
                var localPath = "";
                if (!string.IsNullOrEmpty(info.PosterPath))
                {
                    localPath = await _imageDownloader.Download(info.PosterPath);
                }

                var MovieDetails = new MovieDetails()
                {
                    Title       = info.Title,
                    Id          = info.Id,
                    Genre       = (from x in info.Genres select x.Name).ToList(),
                    ReleaseDate = info.ReleaseDate,
                    Description = info.Overview,
                    ImagePath   = localPath
                };

                MovieDetails.Actors = await getCredits(MovieDetails.Id);

                if (MovieDetails != null)
                {
                    _movies.Add(MovieDetails);
                }
            }
            return(_movies);
        }
コード例 #28
0
        public virtual async Task <Movie> ImportMovieAsync(int TMDB_ID)
        {
            var Movie = new Movie();

            if (TMDB_ID <= 0)
            {
                return(Movie);
            }

            MovieDetails movieDetails = await _TMDBapi.FetchMovieDetailsAsync(TMDB_ID);

            if (movieDetails == null)
            {
                return(Movie);
            }

            Movie.TMDB_ID = movieDetails.id;
            Movie.Title   = movieDetails.title;

            Movie.Year = Convert.ToDateTime(movieDetails.release_date).Year;

            Movie.Genres = new List <Genre>();
            movieDetails?.genres.ToList()
            .ForEach(genre => Movie.Genres.Add(new Genre(genre.id)));


            if (Movie.TMDB_ID <= 0)
            {
                return(Movie);
            }


            Movie.IMDB_ID = movieDetails.imdb_id;

            var ratingFound = false;

            foreach (var releasedate in movieDetails.release_dates?.results)
            {
                if ((releasedate.iso_3166_1 != "US") || (releasedate.release_dates == null))
                {
                    continue;
                }

                foreach (var rd in releasedate.release_dates)
                {
                    if (rd.type == ReleaseDateType.Premiere || rd.type == ReleaseDateType.Theatrical)
                    {
                        Movie.Rating = Movie.RatingFromString(rd.certification);
                        ratingFound  = true;
                        break;
                    }
                }
                if (ratingFound == true)
                {
                    break;
                }
            }

            return(Movie);
        }
コード例 #29
0
ファイル: UpdatePageActor.xaml.cs プロジェクト: krzyGa/BSK-2
        private void buttonReturn_Click(object sender, RoutedEventArgs e)
        {
            var          movie        = (Movie)movieObject;
            MovieDetails movieDetails = new MovieDetails(movie, CurrentUserRights, CurrentUserLogin);

            this.NavigationService.Navigate(movieDetails);
        }
コード例 #30
0
        public PromptOptions GenerateMovieDetailsAttachment(MovieDetails movieDetails)
        {
            var paths            = new[] { ".", "Cards", "movieDetails.json" };
            var adaptiveCardJson = File.ReadAllText(Path.Combine(paths));

            AdaptiveCardParseResult result = AdaptiveCard.FromJson(adaptiveCardJson);
            AdaptiveCard            card   = result.Card;

            ((AdaptiveTextBlock)card.Body.First()).Text = "Movie details";
            ((AdaptiveImage)((AdaptiveColumnSet)card.Body[1]).Columns.First().Items.First()).Url = new Uri($"https://image.tmdb.org/t/p/w500/{movieDetails.PosterPath}");

            ((AdaptiveTextBlock)((AdaptiveColumnSet)card.Body[1]).Columns[1].Items.First()).Text = movieDetails.Title;
            ((AdaptiveTextBlock)((AdaptiveColumnSet)card.Body[1]).Columns[1].Items[1]).Text      = $"Released: {movieDetails.ReleaseDate}";
            ((AdaptiveTextBlock)((AdaptiveColumnSet)card.Body[1]).Columns[1].Items[2]).Text      = $"Genres: {string.Join(", ", movieDetails.Genres.Select(x => x.Name))}";
            ((AdaptiveTextBlock)((AdaptiveColumnSet)card.Body[1]).Columns[1].Items[3]).Text      = $"Status: {movieDetails.Status}";
            ((AdaptiveTextBlock)((AdaptiveColumnSet)card.Body[1]).Columns[1].Items[4]).Text      = $"Rating: {movieDetails.VoteAverage}";
            ((AdaptiveTextBlock)((AdaptiveColumnSet)card.Body[1]).Columns[1].Items[5]).Text      = $"Runtime: {movieDetails.Runtime} min";
            ((AdaptiveTextBlock)card.Body[2]).Text = movieDetails.Overview;

            ((AdaptiveOpenUrlAction)card.Actions.First()).Url = new Uri($"https://www.imdb.com/title/{movieDetails.ImdbId}");

            return(new PromptOptions
            {
                Prompt = (Activity)MessageFactory.Attachment(new Attachment()
                {
                    ContentType = "application/vnd.microsoft.card.adaptive",
                    Content = JObject.FromObject(card)
                })
            });
        }
コード例 #31
0
        private void OpenSelectedMovie(string Name, string Language)
        {
            DataSet dtStMovie;
            Movie tmpMov = new Movie();
            tmpMov.Name = Name;
            tmpMov.Language = Language;
            dtStMovie = dbObj.GetMovieDetails(tmpMov.Name, tmpMov.Language);
            if (dtStMovie.Tables[0].Rows.Count != 0)
            {
                if (!dtStMovie.Tables[0].Rows[0].IsNull("Year"))
                    tmpMov.Year = (int)dtStMovie.Tables[0].Rows[0]["Year"];
                tmpMov.IsWatched = (bool)dtStMovie.Tables[0].Rows[0]["Seen"];
                if (!dtStMovie.Tables[0].Rows[0].IsNull("SeenDate"))
                    tmpMov.WhenSeen = (DateTime)dtStMovie.Tables[0].Rows[0]["SeenDate"];
                tmpMov.Size = (float)(double)dtStMovie.Tables[0].Rows[0]["Size"];
                if (!dtStMovie.Tables[0].Rows[0].IsNull("MyRating"))
                    tmpMov.MyRating = (int)dtStMovie.Tables[0].Rows[0]["MyRating"];
                if (!dtStMovie.Tables[0].Rows[0].IsNull("IMDBRating"))
                    tmpMov.IMDBRating = (float)Convert.ToDouble(dtStMovie.Tables[0].Rows[0]["IMDBRating"]);
                if (!dtStMovie.Tables[0].Rows[0].IsNull("IMDBID"))
                    tmpMov.IMDBID = (string)dtStMovie.Tables[0].Rows[0]["IMDBID"];
                if (!dtStMovie.Tables[0].Rows[0].IsNull("Quality"))
                    tmpMov.Quality = (string)dtStMovie.Tables[0].Rows[0]["Quality"];
                foreach (string genre in dtStMovie.Tables[0].Rows[0]["Genre"].ToString().Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries))
                {
                    tmpMov.Genre.Add(genre);
                }
                foreach (DataRow dr in dtStMovie.Tables[0].Rows)
                {
                    tmpMov.Locations.Add(dr.Field<string>("Location"));
                    tmpMov.Checksums.Add(dr.Field<string>("Checksum"));
                    if (dr.Field<object>("LocationSize") != null)
                        tmpMov.LocationSize.Add((float)dr.Field<double>("LocationSize"));
                }

                MovieDetails fmmovie = new MovieDetails(tmpMov);
                fmmovie.Show();
            }
            else
                MessageHandler.ShowError("Refresh and try again!", "Error");
        }