Ejemplo n.º 1
0
        public MovieDetailModel GetDetail(int id)
        {
            string sql = "select m.id,d.typename,m.name,m.movieurl,m.introduce,m.actors";

            sql += " from [Movies] m";
            sql += " inner join dbo.DicType d on m.typename=d.typeid ";
            sql += " where id=" + id;

            MovieDetailModel model = new MovieDetailModel();

            try
            {
                Database database = DatabaseFactory.CreateDatabase("MainConnection");
                using (DbCommand cmd = database.GetSqlStringCommand(sql))
                {
                    using (IDataReader reader = database.ExecuteReader(cmd))
                    {
                        while (reader.Read())
                        {
                            model = new MovieDetailModel(reader);
                        }
                    }
                }
                return(model);
            }
            catch (Exception ex)
            {
                return(new MovieDetailModel());
            }
        }
        public async Task <MovieDetailModel> GetMovieDetailsAsync(string movieName)
        {
            var queryString = $"?t={movieName}&apikey={_apiConfiguration.Key}";
            var response    = await _httpClient.GetStringAsync(queryString);

            JObject json = JObject.Parse(response);

            if (json.SelectToken("Response").Value <string>() == "True")
            {
                var movieDetails = new MovieDetailModel
                {
                    Title       = json.SelectToken("Title").Value <string>(),
                    Year        = json.SelectToken("Year").Value <string>(),
                    Director    = json.SelectToken("Director").Value <string>(),
                    Actors      = json.SelectToken("Actors").Value <string>(),
                    IMDBRating  = json.SelectToken("imdbRating").Value <string>(),
                    PosterImage = json.SelectToken("Poster").Value <string>(),
                    Plot        = json.SelectToken("Plot").Value <string>()
                };

                return(movieDetails);
            }

            return(new MovieDetailModel
            {
                Title = movieName
            });
        }
Ejemplo n.º 3
0
        public void Update(MovieDetailModel movieDetailModel)
        {
            var movie = FromModel(movieDetailModel);

            DbContext.Update(movie);
            DbContext.SaveChanges();
        }
        public IActionResult Detail(int movieId)
        {
            var movie = _movies.GetById(movieId);

            var movieAvailiability = new MovieAvailabilityModel()
            {
                DvdAvailiable     = _checkout.IsDvdCheckedOut(movieId),
                BlueRayAvailiable = _checkout.IsBlueRayCheckedOut(movieId)
            };

            var movieDetail = new MovieDetailModel()
            {
                MovieId            = movie.MovieId,
                Title              = movie.Title,
                Director           = movie.Director,
                MovieGenre         = movie.MovieGenres,
                ReleaseDate        = movie.ReleaseDate,
                Synopsis           = movie.Synopsis,
                Rating             = movie.Rating,
                ImageUrl           = movie.PosterUrl,
                MovieActors        = movie.MovieActors,
                MovieAvailiability = movieAvailiability
            };

            return(View(movieDetail));
        }
Ejemplo n.º 5
0
        public void Add(MovieDetailModel movieDetailModel)
        {
            var movie = FromModel(movieDetailModel);

            DbContext.Add(movie);
            DbContext.SaveChanges();
            movieDetailModel.Id = movie.Id;
        }
Ejemplo n.º 6
0
        public MovieDetailModel GetDetail(int id)
        {
            var db    = new MovieData();
            var movie = db.Movies.Find(id);
            var model = new MovieDetailModel(movie);

            return(model);
        }
Ejemplo n.º 7
0
 public void Update(MovieDetailModel model)
 {
     using (var dbContext = _dbContextSqlFactory.CreateDbContext())
     {
         var entity = MovieMapper.MapMovieDetailModelToEntity(model);
         dbContext.Movies.Update(entity);
         dbContext.SaveChanges();
     }
 }
Ejemplo n.º 8
0
 public MovieDetailModel Create(MovieDetailModel model)
 {
     using (var dbContext = _dbContextSqlFactory.CreateDbContext())
     {
         var entity = MovieMapper.MapMovieDetailModelToEntity(model);
         dbContext.Movies.Add(entity);
         dbContext.SaveChanges();
         return(MovieMapper.MapMovieEntityToDetailModel(entity));
     }
 }
Ejemplo n.º 9
0
        /// <summary>
        /// 详情页面
        /// </summary>
        /// <returns></returns>
        public ActionResult MovieDetail(int id = 0)
        {
            //去数据库数据,把id传进去
            MovieDB          db = new MovieDB();
            MovieDetailModel m  = db.GetDetail(id);

            ViewBag.movieModel = m;

            return(View());
        }
Ejemplo n.º 10
0
        private void UpdateMovieListViewWithNewItem(MovieDetailModel movieDetailModel)
        {
            var movieListModel = new MovieListModel()
            {
                Id   = movieDetailModel.Id,
                Name = movieDetailModel.OriginalTitle
            };

            Movies.Add(movieListModel);
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Fetches gallery image Url-s and populates the movie object with it
        /// </summary>
        public async Task LoadMovieGallery(MovieDetailModel movieToPopulate, int retryCount, int delayMilliseconds, bool fromCache)
        {
            var response = await _tmdbApiService.TryGetMovieImages(movieToPopulate.Id, _settings.SearchLanguage, otherLanguage : null, includeLanguageless : true, retryCount : retryCount, delayMilliseconds : delayMilliseconds, fromCache : true);

            if (response.HttpStatusCode.IsSuccessCode())
            {
                movieToPopulate.ImageDetailCollection = response.ImageDetailCollection;
                _movieDetailModelConfigurator.SetGalleryImageSources(movieToPopulate);
            }
        }
Ejemplo n.º 12
0
        private void UpdateMovieListWithExistingItem(MovieDetailModel movieDetailModelUpdated)
        {
            var item  = Movies.FirstOrDefault(a => a.Id == movieDetailModelUpdated.Id);
            var index = Movies.IndexOf(item);

            if (index != -1)
            {
                Movies[index].Name = movieDetailModelUpdated.OriginalTitle;
                CollectionViewSource.GetDefaultView(Movies).Refresh();
            }
        }
Ejemplo n.º 13
0
 public Movie FromModel(MovieDetailModel model)
 {
     return(new Movie
     {
         Id = model.Id,
         Title = model.Title,
         Description = model.Description,
         Duration = model.Duration,
         Type = model.Type,
         Year = model.Year,
         Poster = model.Poster
     });
 }
Ejemplo n.º 14
0
        private void OnCloseSearchMoviesView(MovieDetailModel selectedItem)
        {
            var listModel = new MovieListModel()
            {
                Id = selectedItem.Id
            };

            Messenger.Default.Send(listModel);

            ToggleSearchView = false;
            ToggleTabView    = true;
            SearchQuery      = null;
        }
Ejemplo n.º 15
0
 public static MovieEntity MapMovieDetailModelToEntity(MovieDetailModel model)
 {
     return(new MovieEntity
     {
         Id = model.Id,
         OriginalTitle = model.OriginalTitle,
         CzechTitle = model.CzechTitle,
         Genre = model.Genre,
         PosterImageUrl = model.PosterImageUrl,
         CountryOfOrigin = model.CountryOfOrigin,
         Length = model.Length,
         Description = model.Description
     });
 }
Ejemplo n.º 16
0
 public static MovieNewWrapper MovieDetailToMovieNewWrapper(MovieDetailModel movieDetailModel)
 {
     return(new MovieNewWrapper
     {
         Id = movieDetailModel.Id,
         OriginalTitle = movieDetailModel.OriginalTitle,
         CzechTitle = movieDetailModel.CzechTitle,
         Genre = movieDetailModel.Genre,
         CountryOfOrigin = movieDetailModel.CountryOfOrigin,
         Length = movieDetailModel.Length,
         Description = movieDetailModel.Description,
         PosterImageUrl = movieDetailModel.PosterImageUrl
     });
 }
Ejemplo n.º 17
0
 private void OnMovieAddNewReceived(MovieNewWrapper movieDetailModel)
 {
     LoadPeople();
     CanSaveFlag        = true;
     CanDeleteFlag      = false;
     DisplayDetailModel = null;
     EditDetailModel    = new MovieDetailModel
     {
         Id = movieDetailModel.Id
     };
     Actors.Clear();
     Directors.Clear();
     Ratings.Clear();
 }
Ejemplo n.º 18
0
        /// <summary>
        /// Fetches video clip thumbnail data and populates the movie object with it
        /// </summary>
        public async Task LoadVideoThumbnailCollection(MovieDetailModel movieToPopulate, int retryCount, int delayMilliseconds, bool fromCache)
        {
            if (movieToPopulate.VideoThumbnails != null)
            {
                return;
            }

            movieToPopulate.VideoThumbnails = new ObservableCollection <ImageModel>();

            List <ImageModel> videoThumbnails = await _videoService.GetVideoThumbnails(movieToPopulate.Id, retryCount : retryCount, delayMilliseconds : delayMilliseconds, fromCache : true);

            foreach (var thumbnail in videoThumbnails)
            {
                movieToPopulate.VideoThumbnails.Add(thumbnail);
            }
        }
        // GET: MoviesBooking/Create
        public ActionResult Create()
        {
            string userId       = User.Identity.GetUserId();
            var    movieDetails = (from mb in db.MovieBookingDetails where mb.UserId == userId select new { mb.MovieId, mb.Movy.Name, mb.NoOfSeatsBooked }).ToList();
            List <MovieDetailModel> lstMovie = new List <MovieDetailModel>();

            var newList = movieDetails.GroupBy(x => x.Name).Select(grp => grp.ToList()).ToList();

            foreach (var item in newList)
            {
                MovieDetailModel model = new MovieDetailModel();
                model.Name            = item.Select(x => x.Name).FirstOrDefault();
                model.NoOfSeatsBooked = item.Select(x => x.NoOfSeatsBooked).FirstOrDefault();
                lstMovie.Add(model);
            }
            return(View(lstMovie));
        }
Ejemplo n.º 20
0
        public void Create_Movie_DoesNotThrowAndEqualsCreated()
        {
            var movieModel = new MovieDetailModel
            {
                Id              = Guid.Parse("5947ae88-344a-465a-b8ae-2af1e216097a"),
                OriginalTitle   = "Star Wars: Episode IV - New Hope",
                CzechTitle      = "Star Wars: Epizoda IV - Nová nadìje",
                Genre           = GenreType.ScienceFiction,
                PosterImageUrl  = "https://img.csfd.cz/files/images/film/posters/162/398/162398464_ac2bec.jpg?h180",
                CountryOfOrigin = "USA",
                Length          = TimeSpan.FromMinutes(121),
                Description     =
                    "Rytíøi Jedi byli vyhlazeni a Impérium vládne galaxii pevnou rukou. Malá skupina povstalcù se odváží vzdorovat a ukradne plány k nejmocnìjší zbrani Impéria, Hvìzdì smrti. Imperátorùv nejvìrnìjší služebník, Darth Vader, musí najít plány a skrytou základnu povstalcù. Zpráva o princeznì Lei a vùdci rebelù se dostane až k obyèejnému farmáøi, Lukovi Skywalkerovi. Ten se øídí svým osudem, zachraòuje princeznu a pomáhá povstalcùm svrhnout Impérium spoleènì s takovými nezapomenutelnými spojenci jako: Obi-Wan Kenobi, domýšlivý Han Solo, loajální Chewbacca a droidové R2-D2 a C3PO.",
            };

            var returnedModel = RepositorySUT.Create(movieModel);

            Assert.Equal(movieModel, returnedModel, MovieDetailModel.MovieDetailModelComparer);
        }
Ejemplo n.º 21
0
        private async void showMovieDetail(int id)
        {
            MovieDetailModel md = await MovieApiClientService.GetMovieDetailById(id);

            if (md == null)
            {
                Console.WriteLine("no detail for ID " + id);
                return;
            }
            Console.WriteLine(md.Description);
            title.Text       = md.Title;
            description.Text = md.Description;
            ObservableCollection <Actor> actors = new ObservableCollection <Actor>();

            actorslist.ItemsSource = actors;
            foreach (Actor a in md.Actors)
            {
                actors.Add(a);
            }
        }
Ejemplo n.º 22
0
        public string Compose(MovieDetailModel movie)
        {
            if (_settings.InfoLinkTargetHomePage == InformationLinkTargetHomePage.IMDb)
            {
                if (!string.IsNullOrEmpty(movie.ImdbId))
                {
                    return(IMDb_Movie_Base + movie.ImdbId);
                }
            }
            else if (_settings.InfoLinkTargetHomePage == InformationLinkTargetHomePage.TMDb)
            {
                return(TMDb_Movie_Base + movie.Id);
            }
            else if (_settings.InfoLinkTargetHomePage == InformationLinkTargetHomePage.Invalid)
            {
                return(null);
            }

            return(null);
        }
        public List <MovieDetailModel> GetAllMovies()
        {
            List <MovieDetailModel> moviesList = new List <MovieDetailModel>();
            MovieDetailModel        movie1     = new MovieDetailModel();

            movie1.Id          = 1;
            movie1.Poster      = "images/DayInTheLifeOfNETDeveloper.png";
            movie1.Title       = "A day in the life of a .NET Developer";
            movie1.Director    = "Rishabh Verma";
            movie1.ShowTime    = "11:00 AM";
            movie1.ReleaseDate = "23/03/2018";
            movie1.Description = "Relive a .NET developer's daily life and share his joy, excitement and experiences while coding .NET stuff";
            moviesList.Add(movie1);

            MovieDetailModel movie2 = new MovieDetailModel();

            movie2.Id          = 2;
            movie2.Poster      = "images/DevVsTest.png";
            movie2.Title       = "Developers Vs Testers";
            movie2.Director    = "Neha Shrivastava";
            movie2.ShowTime    = "3:00 PM";
            movie2.ReleaseDate = "06/04/2018";
            movie2.Description = "Bored !?!? Add spice to your life by watching this Developers Vs Testers battle, which is surely more fresh and exciting than the TV soaps you have been watching. From invalid bug, no repro bugs, duplicate bugs to testing blocked due to high severity issue, it has all the drama that unfolds in an IT company";

            moviesList.Add(movie2);

            MovieDetailModel movie3 = new MovieDetailModel();

            movie3.Id          = 3;
            movie3.Poster      = "images/Cers.png";
            movie3.Title       = "The C# ers";
            movie3.Director    = "Neha Shrivastava";
            movie3.ShowTime    = "6:00 PM";
            movie3.ReleaseDate = "13/04/2018";
            movie3.Description = "The coding avengers - C#ers";

            moviesList.Add(movie3);
            return(moviesList);
        }
Ejemplo n.º 24
0
        public async Task <IActionResult> Detail(int id)
        {
            Movie movie = await _movies.GetById(id);

            if (movie != null)
            {
                ICollection <Actor> actors = await _movies.GetActors(movie.Id);

                ICollection <Genre> genres = await _movies.GetGenres(movie.Id);


                var detailModel = new MovieDetailModel
                {
                    Id       = movie.Id,
                    Rank     = movie.Rank,
                    Title    = movie.Title,
                    Year     = movie.Year,
                    Director = new DirectorListing()
                    {
                        Id = movie.Director.Id, Name = movie.Director.Name
                    },
                    Runtime     = movie.Runtime,
                    Revenue     = movie.Revenue,
                    Metascore   = movie.Metascore,
                    Description = movie.Description,
                    Actors      = actors
                                  .Select(actor => new KeyValuePair <int, string>(actor.Id, actor.Name))
                                  .ToDictionary(kvp => kvp.Key, kvp => kvp.Value),
                    Genres = genres
                             .Select(genre => new KeyValuePair <int, string>(genre.Id, genre.Name))
                             .ToDictionary(kvp => kvp.Key, kvp => kvp.Value)
                };

                return(View(detailModel));
            }

            return(NotFound());
        }
Ejemplo n.º 25
0
 public IActionResult AddMovie(MovieDetailModel movieDetailModel, IFormFile file)
 {
     log.Info("Adding a movie started....");
     try
     {
         movieDetailModel.Poster = Path.GetExtension(file.FileName);
         Service.Add(movieDetailModel);
     }
     catch (Exception ex)
     {
         log.Error(ex);
     }
     if (file != null)
     {
         string ImageName = movieDetailModel.Id + Path.GetExtension(file.FileName);
         string SavePath  = Path.Combine(_configuration["ImagesFolder"], ImageName);
         using (var stream = new FileStream(SavePath, FileMode.Create))
         {
             file.CopyTo(stream);
         }
     }
     return(RedirectToAction("Index"));
 }
        public void SetGalleryImageSources(MovieDetailModel movie)
        {
            string baseUrl = ImageBaseUrl;

            if (movie.MovieImages.Count < 2)
            {
                if (movie.ImageDetailCollection.Backdrops?.Length > 0)
                {
                    foreach (ImageModel backdrop in movie.ImageDetailCollection.Backdrops.Skip(1))
                    {
                        backdrop.FilePath = baseUrl + _tmdbConfiguration.Images.BackdropSizes[1] + backdrop.FilePath;
                        movie.MovieImages.Add(backdrop);
                    }
                }
                else if (movie.ImageDetailCollection.Posters?.Length > 0)
                {
                    foreach (ImageModel poster in movie.ImageDetailCollection.Posters.Skip(1))
                    {
                        poster.FilePath = baseUrl + _tmdbConfiguration.Images.PosterSizes.Last() + poster.FilePath;
                        movie.MovieImages.Add(poster);
                    }
                }
            }
        }
Ejemplo n.º 27
0
        /// <summary>
        /// tries to POPULATE the existing movie object with details
        /// </summary>
        /// <param name="movieToPopulate">Movie object to populate</param>
        /// <returns>ApiCommunicationServiceResponseBase class extended with AccountMovieStates property</returns>
        public async Task <TryGetMovieDetailsWithAccountStatesResponse> TryGetMovieDetailsWithAccountStates(MovieDetailModel movieToPopulate, int id, string language = null, int retryCount = 0, int delayMilliseconds = 1000)
        {
            var response = await _cachedSearchClient.GetMovieDetailsWithAccountStates(_settings.SessionId, id, language, retryCount, delayMilliseconds);

            AccountMovieStates states = null;

            if (response.HttpStatusCode.IsSuccessCode())
            {
                if (movieToPopulate != null)
                {
                    JsonConvert.PopulateObject(response.Json, movieToPopulate);
                }

                if (response.HttpStatusCode == HttpStatusCode.OK)
                {
                    var jsonSettings = new JsonSerializerSettings()
                    {
                        Error = delegate(object sender, ErrorEventArgs args) { args.ErrorContext.Handled = true; }
                    };
                    var tmdbResponse = JObject.Parse(response.Json);
                    var result       = tmdbResponse["account_states"];

                    if (result != null)
                    {
                        states = result.ToObject <AccountMovieStates>(JsonSerializer.Create(jsonSettings));
                    }
                }
            }
            return(new TryGetMovieDetailsWithAccountStatesResponse(response.HttpStatusCode, states));
        }
        public async Task <IActionResult> Submit(MovieDetailModel model)
        {
            var movieDetail = await _movieDetailsClient.GetMovieDetailsAsync(model.Title);

            return(View("Index", movieDetail));
        }
Ejemplo n.º 29
0
        /// <summary>
        /// Unclean function.Returns value and modifies state
        /// reason API server aggergates two unrelated functions into a single fast call
        /// </summary>
        public async Task <AccountMovieStatesDto> PopulateMovieWithDetailsAndFetchStates(MovieDetailModel movieToPopulate, int retryCount, int delayMilliseconds)
        {
            var response = await _tmdbApiService.TryGetMovieDetailsWithAccountStates(movieToPopulate, movieToPopulate.Id, _settings.SearchLanguage, retryCount : retryCount, delayMilliseconds : delayMilliseconds);

            if (response.HttpStatusCode.Is200Code())
            {
                var result = response.AccountMovieStates;
                return(new AccountMovieStatesDto(result));
            }
            else
            {
                throw new Exception($"Could not populate movie details and movie states object, service responded {response.HttpStatusCode}");
            }
        }
Ejemplo n.º 30
0
 public MovieDetailResponseModel(string provider, MovieDetailModel payload)
 {
     _Provider = provider;
     Payload   = payload;
 }