Exemplo n.º 1
0
        public ActionResult GetDetailFilmFromIMDB(string filmName)
        {
            if (filmName == null)
            {
                return(Json(new
                {
                    result = "KO",
                    value = "null",
                }, JsonRequestBehavior.AllowGet));
            }

            //get data and serilize
            IMDBModel result = IMDBModelHelper.GetMovieInformation(filmName);

            TempData["FilmUpdate"] = result;
            if (result == null)
            {
                return(Json(new
                {
                    result = "KO",
                    value = "null",
                }, JsonRequestBehavior.AllowGet));
            }

            IMDBViewModel resultVm = new IMDBViewModel();

            resultVm = MappingDataMovie(result);
            return(Json(new
            {
                result = "OK",
                value = resultVm,
            }, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 2
0
        private IMDBViewModel MappingDataMovie(IMDBModel model)
        {
            IMDBViewModel modelresult = new IMDBViewModel();

            modelresult.MovieName        = model.MovieName;
            modelresult.MovieBudget      = model.MovieBudget;
            modelresult.MovieDuration    = model.MovieDuration;
            modelresult.MovieReleaseDate = model.MovieReleaseDate;
            modelresult.MovieGenre       = model.MovieGenre[0];
            modelresult.MovieDirector    = model.MovieDirector[0];
            modelresult.MovieLink        = model.MovieLink;
            modelresult.MovieLinkPoster  = model.MovieLinkPoster;
            modelresult.MovieLinkTrailer = model.MovieLinkTrailer;
            modelresult.MovieProduction  = model.MovieProduction[0];
            modelresult.MovieMusicby     = model.MovieMusicby[0];
            modelresult.MovieStarActor   = model.MovieStarActor[0];
            modelresult.MovieWriter      = model.MovieWriter[0];

            for (int i = 1; i < model.MovieGenre.Count; i++)
            {
                modelresult.MovieGenre += ", " + model.MovieGenre[i];
            }

            for (int i = 1; i < model.MovieDirector.Count; i++)
            {
                modelresult.MovieDirector += ", " + model.MovieDirector[i];
            }

            for (int i = 1; i < model.MovieProduction.Count; i++)
            {
                modelresult.MovieProduction += ", " + model.MovieProduction[i];
            }

            for (int i = 1; i < model.MovieMusicby.Count; i++)
            {
                modelresult.MovieMusicby += ", " + model.MovieMusicby[i];
            }

            for (int i = 1; i < model.MovieStarActor.Count; i++)
            {
                modelresult.MovieStarActor += ", " + model.MovieStarActor[i];
            }

            for (int i = 1; i < model.MovieWriter.Count; i++)
            {
                modelresult.MovieWriter += ", " + model.MovieWriter[i];
            }

            return(modelresult);
        }