public IActionResult Detail(int id) { Movie movieFromDb = _movieDatabase.GetMovie(id); MovieDetailViewModel movie = new MovieDetailViewModel() { Title = movieFromDb.Title, Description = movieFromDb.Description, Genre = movieFromDb.Genre, Releasedate = movieFromDb.Releasedate }; return(View(movie)); }
public IActionResult Detail(int id) { Movie movieFromDb = _context.GetMovie(id); MovieDetailViewModel model = new MovieDetailViewModel() { Title = movieFromDb.Title, Description = movieFromDb.Description, //Genre = movieFromDb.Genre, Length = movieFromDb.Length, ReleaseDate = movieFromDb.ReleaseDate }; return(View(model)); }
public ActionResult Edit(int id) { var movieInDb = _context.Movies.Single(m => m.Id == id); if (movieInDb == null) { return(HttpNotFound("Error in the Movie Id")); } var viewModel = new MovieDetailViewModel { Movie = movieInDb, Genres = _context.Genres.ToList() }; return(View("Details", viewModel)); }
public IActionResult MovieDetails(Movie movie) { var movieDetails = new MovieDetailViewModel { AiringMovies = _movieLogic.GetAiringsFromMovieStartingFromDate(movie, DateTime.Today), Movie = _movieLogic.GetMovieById(movie.Id), Reviews = _movieLogic.GetAllReviewsFromMovie(movie) }; foreach (var airingMovie in movieDetails.AiringMovies) { airingMovie.Movie = movie; } return(View(movieDetails)); }
// GET: MovieViewModels/Edit/5 public async Task <ActionResult> Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } using (var client = new HttpClient()) { client.BaseAddress = new Uri("http://localhost:50658/"); client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); HttpResponseMessage response = await client.GetAsync("api/Movies/" + id); if (response.IsSuccessStatusCode) { MovieDetailViewModel movieViewModel = await response.Content.ReadAsAsync <MovieDetailViewModel>(); response = await client.GetAsync("api/Directors"); if (response.IsSuccessStatusCode) { List <DirectorViewModel> directorsList = await response.Content.ReadAsAsync <List <DirectorViewModel> >(); var dId = directorsList.Where(d => d.Name == movieViewModel.DirectorName).FirstOrDefault().Id; int id2 = 0; if (id.HasValue) { id2 = id.Value; } ViewBag.DirectorId = new SelectList(directorsList, "Id", "Name", dId); Movie movie = new Movie { Id = id2, Title = movieViewModel.Title, Year = movieViewModel.Year, Price = movieViewModel.Price, Genre = movieViewModel.Genre, DirectorId = dId }; return(View(movie)); } } } return(HttpNotFound()); }
public void TestCase() { //Arrange var vm = new MovieDetailViewModel(isTest); //vm.Number1 = 2; //vm.Number2 = 3; //Act //vm.ButtonCalculate.Execute(null); vm.Perkalian(2, 2); //Assert //Assert.IsTrue(5 == 5, "Salah"); Assert.AreNotEqual(5, vm.Result); }
// Helper function which checks if movies exists in a user's watchlist // If it does not then it creates a new instance of it // If it does then it overwrites the data inside the database private static void AddMovieToUserList(MovieDetailViewModel movieDetailViewModel, UserList currUser) { // If Movie is not in the list if (!currUser.WatchList.Where(movie => movie.Title == movieDetailViewModel.Movie.Title).Any()) { currUser.WatchList.Add(new UserMovie() { Title = movieDetailViewModel.Movie.Title, Image = movieDetailViewModel.Movie.Image, Status = movieDetailViewModel.Status, PublicMovieId = movieDetailViewModel.Movie.PublicMovieId }); } else { // Update status for current user currUser.WatchList.FirstOrDefault(movie => movie.PublicMovieId == movieDetailViewModel.Movie.PublicMovieId).Status = movieDetailViewModel.Status; } }
protected override async void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); var data = Intent.GetStringExtra("movie"); var movie = Newtonsoft.Json.JsonConvert.DeserializeObject <MovieModel>(data); viewModel = new MovieDetailViewModel(); viewModel.Movie = movie; await viewModel.GetSimilarMovies(movie.Id); FindViewById <TextView>(Resource.Id.movie_overview).Text = movie.Overview; FindViewById <TextView>(Resource.Id.movie_title).Text = movie.Title; FindViewById <TextView>(Resource.Id.release_date).Text = "Release date: 01/05/2001"; //TODO: format this date! FindViewById <TextView>(Resource.Id.votes_amount).Text = Convert.ToString(movie.VoteCount); ImageView coverImageView = FindViewById <ImageView>(Resource.Id.movie_cover); var url = await viewModel.GetMovieCover(movie.Id); try { Uri uri = Uri.Parse(url); Picasso.With(this).Load(uri).Fit().Into(coverImageView); } catch (Exception ex) { Console.WriteLine("Error getting the movie cover image: ", ex.Message); } //// Create a new fragment and a transaction. Android.App.FragmentTransaction fragmentTx = this.FragmentManager.BeginTransaction(); MovieDetailAdapter adapter = new MovieDetailAdapter(this, viewModel); MovieCategoryFragment <MovieDetailViewModel> aCategoryFragment = new MovieCategoryFragment <MovieDetailViewModel>(viewModel, adapter); ////// The fragment will have the ID of Resource.Id.fragment_container. fragmentTx.Add(Resource.Id.similar_movies, aCategoryFragment); ////// Commit the transaction. fragmentTx.Commit(); }
// GET: MovieViewModels/Details/5 public async Task <ActionResult> Details(int?id) { using (var client = new HttpClient()) { client.BaseAddress = new Uri("http://localhost:50658/"); client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); HttpResponseMessage response = await client.GetAsync("api/Movies/" + id); if (response.IsSuccessStatusCode) { MovieDetailViewModel movie = await response.Content.ReadAsAsync <MovieDetailViewModel>(); return(View(movie)); } } return(HttpNotFound()); }
public async Task <ActionResult> Edit(Guid id) { var existingMovie = await _movieRepository.GetMovieById(id); var genres = await _genreRepository.GetAllGenres( ); if (existingMovie != null) { var vm = new MovieDetailViewModel { Title = existingMovie.Title, Director = existingMovie.Director, GenreId = existingMovie.Genre.Id, Genres = genres }; return(View(vm)); } return(RedirectToAction("Index")); }
//save a movie to watchedlist an if exist in the watchList remove it from there public async Task <ActionResult> SaveToWatchedList(int id) { MovieDetailViewModel movie = new MovieDetailViewModel(); var baseAddress = new Uri("https://api.themoviedb.org/3/"); using (var httpClient = new HttpClient { BaseAddress = baseAddress }) { httpClient.DefaultRequestHeaders.TryAddWithoutValidation("accept", "application/json"); using (var response = await httpClient.GetAsync($"movie/{id}?api_key=0ac277c3f170caa0df815398709d9bb2&language=hu-BR")) { string jsonFile = await response.Content.ReadAsStringAsync(); movie = JsonConvert.DeserializeObject <MovieDetailViewModel>(jsonFile); } } int actualUser = (int)Session["userId"]; Watched myWatchedMovie = new Watched(); Watchlist myOldMovie = new Watchlist(); var myMovieList = db.Watched.Where(m => m.UserId == actualUser).Select(m => m.MovieId).ToList(); var myOldMovieList = db.Watchlist.Where(m => m.UserID == actualUser).Select(m => m.MovieId).ToList(); if (!myMovieList.Contains(movie.Id)) { myWatchedMovie.MovieId = movie.Id; myWatchedMovie.ImgPath = movie.Poster_path; myWatchedMovie.UserId = actualUser; myWatchedMovie.Title = movie.Title; myWatchedMovie.ReleaseDate = movie.Release_date; myWatchedMovie.Runtime = movie.Runtime; db.Watched.Add(myWatchedMovie); db.SaveChanges(); } if (myOldMovieList.Contains(movie.Id)) { myOldMovie = db.Watchlist.Where(m => m.MovieId == movie.Id).FirstOrDefault(); db.Watchlist.Remove(myOldMovie); db.SaveChanges(); } return(RedirectToAction("Index", "Watchlist", new { search = movie.Id })); }
public IActionResult Details(int Id) { // var isSignedIn = this._signinManager.IsSignedIn(HttpContext.User); var currentUserId = this._signInManager.UserManager.GetUserId(HttpContext.User); _currentMediaUser = _mediaService.GetAllMediaUsers().First(p => p.Id == currentUserId); Movie selectedMovie = _mediaService.GetAllMedia().OfType <Movie>().FirstOrDefault(mov => mov.Id == Id); bool isAlreadyRatedByCurrentUser = false; var playlists = new List <PlayList>(); if (_currentMediaUser != null) { var allratings = _mediaService.GetAllRatings().Where(media => media.Id == selectedMovie.Id); isAlreadyRatedByCurrentUser = allratings.Where(media => media.MediaUser.Id == _currentMediaUser.Id).Any(); playlists = _currentMediaUser.Playlists.ToList(); } MovieDetailViewModel model = new MovieDetailViewModel() { MediaId = selectedMovie.Id, Titel = selectedMovie.Titel, Photo = selectedMovie.Photo, Duration = selectedMovie.Duration, IMDBLink = selectedMovie.IMDBLink, Status = selectedMovie.Status, PlayLists = playlists, AveragePoints = selectedMovie.Ratings.Count() > 0 ? selectedMovie.Ratings.Average(r => r.Points) : 0, IsRated = isAlreadyRatedByCurrentUser, AddedByUserName = selectedMovie.MediaUser.UserName, Ratings = selectedMovie.Ratings.ToList(), Reviews = selectedMovie.Ratings.Select(r => r.Review).ToList() }; return(View(model)); }
// GET: Movie/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var movie = _db.Movies.First(r => r.MovieID == id); var movieDetail = _db.MovieDetails.First(r => r.MovieID == id).MovieDetailDto(); var criticRatings = _db.CriticRatings.Where(r => r.MovieDetailID == movieDetail.MovieDetailID); var userRating = _db.UserRatings.FirstOrDefault(r => r.MovieDetailID == movieDetail.MovieDetailID)?.UserRatingDto(); var criticsites = criticRatings.Select(criticRating => criticRating.CriticSite); var ViewModel = new MovieDetailViewModel(new MovieComplete { Movie = movie.MovieDto(), MovieDetail = movieDetail, UserRatings = userRating, CriticRatings = CriticRating.CriticRatingLsitDto(criticRatings).ToList(), CriticSites = CriticSite.CriticSiteLsitDto(criticsites).ToList() }); return(View(ViewModel)); }
public async Task<MovieDetailViewModel> GetMovieInformation(int id) { MovieDetailViewModel result = new MovieDetailViewModel(); try { string completeURL = string.Format("{0}movie/{1}?api_key={2}&language=pt-BR", BaseURL, id, APIKey); var uri = new Uri(string.Format(completeURL, string.Empty)); var response = await client.GetAsync(uri); if (response.IsSuccessStatusCode) { var message = await response.Content.ReadAsStringAsync(); result = JsonConvert.DeserializeObject<MovieDetailViewModel>(message); result.HasError = false; } } catch (Exception ex) { result.HasError = true; result.ErrorMessage = ex.Message.ToString(); } return result; }
public ActionResult Save(MovieDetailViewModel viewModel) { if (!ModelState.IsValid) { viewModel.Genres = _context.Genres.ToList(); return(View("Details", viewModel)); } if (viewModel.Movie.Id == 0) { viewModel.Movie.DateAdded = DateTime.Now; _context.Movies.Add(viewModel.Movie); } else { var movieInDb = _context.Movies.Single(m => m.Id == viewModel.Movie.Id); if (movieInDb == null) { return(HttpNotFound("Error in the Movie Id")); } movieInDb.Title = viewModel.Movie.Title; movieInDb.GenreId = viewModel.Movie.GenreId; movieInDb.ReleaseYear = viewModel.Movie.ReleaseYear; movieInDb.Price = viewModel.Movie.Price; movieInDb.AmountAvailable = viewModel.Movie.AmountAvailable; //To initialize the amount of available units in the database movieInDb.AvailableForRental = viewModel.Movie.AmountAvailable; movieInDb.DateAdded = DateTime.Now; } _context.SaveChanges(); return(RedirectToAction("Index", "Movies")); }
/** Detail a single movie */ public ActionResult Detail(string show, int id) { if (show.Equals("show")) { } var customers = new List <Customer> { new Customer { Name = "Customer1" }, new Customer { Name = "Customer2" } }; var viewModel = new MovieDetailViewModel { Movie = movies.Find(x => x.Id == id), Customers = customers }; return(View(viewModel)); }
public ActionResult GetMovieDetails(string id, string source, string searchString) { MovieDetailViewModel movieDetail = new MovieDetailViewModel(); var moviesList = new Movies(); var moviedetail = moviesList.GetMovieDetails(id); foreach (var item in moviedetail) { StringBuilder genrelist = new StringBuilder(); int genreCount = item.Genres.Count(); int counter = 0; movieDetail.MovieName = item.OriginalTitle; movieDetail.MovideDescription = item.OverView; movieDetail.Poster = item.PosterPath; foreach (var genre in item.Genres) { counter++; genrelist.Append(genre.Name); if (genreCount > 0 && counter != genreCount) { genrelist.Append(","); } } movieDetail.Genres = genrelist.ToString(); } ViewBag.ReturnSource = source; ViewBag.SearchString = searchString; return(View(movieDetail)); }
// Retrieve data from UserMovie and PublicMovie to store in a ViewModel public ActionResult MovieInfo(int?id) { if (id == null) { return(new HttpStatusCodeResult(System.Net.HttpStatusCode.BadRequest)); } // createUserList(); // Create user if one does not already exist PublicMovie publicMovie = db.PublicMovies.Find(id); // Get selected movie if (publicMovie == null) { return(HttpNotFound()); } // Create movie model to store current movie MovieDetailViewModel movieDetailViewModel = new MovieDetailViewModel() { Movie = publicMovie }; // Get logged in user var currUser = db.UserLists.FirstOrDefault(user => user.User.UserName == User.Identity.Name); // If current user is logged in and contains a movie with title of selected movie update the database if (currUser != null && currUser.WatchList.Where(movie => movie.Title == publicMovie.Title).Any()) { movieDetailViewModel.Status = currUser.WatchList.FirstOrDefault(movie => movie.Title == publicMovie.Title).Status; movieDetailViewModel.UserMovieId = currUser.UserListId; } movieDetailViewModel.ReviewsList.AddRange(db.Reviews.Where(review => review.PublicMovieId == publicMovie.PublicMovieId).Take(3)); // Get review for current movie return(View(movieDetailViewModel)); }
public ActionResult Detail(MovieDetailViewModel model) { Movie movie = _movieService.GetMovieDetail(model.Id - 1); return(View(movie)); }
public void ToggleLikeMovieNotInPreferencesTest() { viewModel = new MovieDetailViewModel(movie, preferences); viewModel.ToggleLike(movie); Assert.AreEqual("after_like.png", viewModel.MovieLikeButtonImageSource); }
public void ConstructDetailPageWithMovieNotLikedTest() { viewModel = new MovieDetailViewModel(movie, preferences); Assert.AreEqual("before_like.png", viewModel.MovieLikeButtonImageSource); }
void SetPageData() { BindingContext = new MovieDetailViewModel(this.Navigation); }
public IActionResult MovieDetail(int id) { Movie movieFromDb = _context.GetMovie(id); var userId = User.FindFirstValue(ClaimTypes.NameIdentifier); int ratingAvg = movieFromDb.RatingReviews.Where(rat => rat.MovieId == movieFromDb.Id && rat.Rating > -1).Count() != 0 ? movieFromDb.RatingReviews.Where(rat => rat.MovieId == movieFromDb.Id && rat.Rating > -1).Select(r => r.Rating).Sum() / movieFromDb.RatingReviews.Where(rat => rat.MovieId == movieFromDb.Id && rat.Rating > -1).Count() : -1; int aantalGezien = movieFromDb.UserMovieGezienStatussen.Any(s => s.GezienStatus != null) ? movieFromDb.UserMovieGezienStatussen.Where(s => s.MovieId == movieFromDb.Id && s.GezienStatus != null && s.GezienStatus.Id == 2).Count() : 0; int aantalWilZien = movieFromDb.UserMovieGezienStatussen.Any(s => s.GezienStatus != null) ? movieFromDb.UserMovieGezienStatussen.Where(s => s.MovieId == movieFromDb.Id && s.GezienStatus != null && s.GezienStatus.Id == 3).Count() : 0; int heeftGezien = userId != null && movieFromDb.UserMovieGezienStatussen.Any(s => s.UserId == userId && s.GezienStatus != null) ? movieFromDb.UserMovieGezienStatussen.SingleOrDefault(s => s.MovieId == movieFromDb.Id && s.UserId == userId).GezienStatus.Id : 1; int eigenRating = userId != null && movieFromDb.RatingReviews.Any(rr => rr.UserId == userId) /*movieFromDb.RatingReviews.Count != 0*/ ? movieFromDb.RatingReviews.SingleOrDefault(r => r.MovieId == movieFromDb.Id && r.UserId == userId).Rating : -1; List <SelectListItem> heeftGezienSelectList = new List <SelectListItem>(); foreach (var gezienStatus in _context.GezienStatus) { heeftGezienSelectList.Add(new SelectListItem { Value = gezienStatus.Id.ToString(), Text = gezienStatus.Naam }); } List <SelectListItem> eigenRatingSelectList = new List <SelectListItem>(); eigenRatingSelectList.Add(new SelectListItem { Value = "-1", Text = "Geef rating" }); for (var i = 0; i <= 10; i++) { eigenRatingSelectList.Add(new SelectListItem { Value = i.ToString(), Text = i.ToString() }); } List <RatingReviewViewModel> ratingReviewList = new List <RatingReviewViewModel>(); foreach (var rr in movieFromDb.RatingReviews.Where(r => r.MovieId == id).ToList()) { ratingReviewList.Add(new RatingReviewViewModel { Id = rr.MovieId, Rating = rr.Rating, Review = rr.Review, UserName = rr.User.UserName }); } MovieDetailViewModel movieVM = new MovieDetailViewModel() { Id = movieFromDb.Id, Titel = movieFromDb.Titel, //FotoFile = movieFromDb.Foto, Genres = movieFromDb.Genres.Where(x => x.MovieId == movieFromDb.Id).Select(x => x.Genre.Naam).ToList(), Rating = ratingAvg, EigenRating = eigenRating, EigenRatingSelectList = eigenRatingSelectList, AantalGezien = aantalGezien, AantalWilZien = aantalWilZien, HeeftGezienSelectList = heeftGezienSelectList, HeeftGezien = heeftGezien, RatingReview = ratingReviewList }; return(View(movieVM)); }
public MovieDetailPage(MovieDetails movieDetails) { InitializeComponent(); BindingContext = new MovieDetailViewModel(movieDetails); }
protected override void OnNavigatedTo(NavigationEventArgs e) { var movie = e.Parameter as Movie; this.ViewModel = new MovieDetailViewModel(movie); }
public MovieDetailPage(MovieDetailViewModel viewModel) { InitializeComponent(); BindingContext = viewModel; }