/// <summary> /// Gets the movie information. /// </summary> /// <param name="imbdId">The imbd identifier.</param> public MovieFullInfo GetMovieInfo(string imbdId) { // gets movie info from db var dbInstance = new DbManager(); DbMovieFullInfo movieFromDb = dbInstance.GetMovieByImdbId(imbdId); MovieFullInfo movie = MapFullMovieDbEntitieToBl(movieFromDb); if (movie != null) { return(movie); } // gets movie info from api var service = new MovieBoxApiService(); ApiMovieFullInfo movieFromApi = service.GetMovie(imbdId); if (movieFromApi != null) { DbMovieFullInfo dbMoveEntity = MapApiFullInfoMovieToDb(movieFromApi); // add movie to db dbInstance.AddMovie(dbMoveEntity); MovieFullInfo movieBl = MapFullMovieDbEntitieToBl(dbMoveEntity); return(movieBl); } return(new MovieFullInfo()); }
public ActionResult Create(MovieViewModel vm) { if (!ModelState.IsValid) { ViewBag.DirectorId = new SelectList(db.GetDirectors(), "Id", "Name", vm.Movie.DirectorId); var categories = db.GetCategories(); ViewBag.Genre = new SelectList(categories, "Name", "Name", vm.Movie.Genre); // mporei na mpei kateutheian sto 1o parameter xwris metavlhth return(View(vm)); } db.AddMovie(vm.Movie, vm.SelectedActors); return(RedirectToAction("Index")); }
public ActionResult Create(MovieViewModel vm) { if (!ModelState.IsValid) { var directors = db.GetDirectors().AsEnumerable(); ViewBag.DirectorId = new SelectList(directors, "Id", "Name", vm.Movie.DirectorId); var categories = db.GetCategories(); ViewBag.Genre = new SelectList(categories, "Name", "Name", vm.Movie.Genre); return(View(vm)); } db.AddMovie(vm.Movie, vm.SelectedActors); return(RedirectToAction("Index")); }
/// <summary> /// Gets the movie information. /// </summary> /// <param name="imbdId">The imbd identifier.</param> public IMovieFullInfo GetMovieInfo(string imbdId) { var dbInstance = new DbManager(); IMovieFullInfo movieFromDb = dbInstance.GetMovieByImdbId(imbdId); // gets movie info from db if (movieFromDb != null) { return(movieFromDb); } // gets movie info from api var service = new MovieBoxApiService(); IMovieFullInfo movieFromApi = service.GetMovie(imbdId); if (movieFromApi != null) { dbInstance.AddMovie(movieFromApi); } return(movieFromApi); }