Example #1
0
        public Movie BuildMovie(dynamic jsonData)
        {
            Movie movie = new Movie();
            movie.ApiId = jsonData.code;

            try { movie.PictureUrl = jsonData.poster.href; }
            catch { movie.PictureUrl = null; }

            try { movie.Title = jsonData.title; }
            catch { movie.Title = null; }

            try { movie.OriginalTitle = jsonData.originalTitle; }
            catch { movie.OriginalTitle = null; }

            try { movie.Actors = jsonData.castingShort.actors; }
            catch { movie.Actors = null; }

            try { movie.Director = jsonData.castingShort.directors; }
            catch { movie.Director = null; }

            try
            {
                string releaseString = jsonData.release.releaseDate;
                DateTime releaseDate;
                if (DateTime.TryParse(releaseString, out releaseDate))
                {
                    movie.ReleaseDate = releaseDate.Date;
                }
            }
            catch
            {
            }

            try
            {
                movie.Trailer = BuildProperty(jsonData.trailer, "href");
            }
            catch { }

            try
            {
                movie.LinkList = BuildLink(jsonData.link);
            }
            catch { }

            try { movie.PressRatings = jsonData.statistics.pressRating; }
            catch { movie.PressRatings = null; }

            try { movie.UserRatings = jsonData.statistics.userRating; }
            catch { movie.UserRatings = null; }

            try { movie.Synopsis = jsonData.synopsis; }
            catch { movie.Synopsis = null; }

            return movie;
        }
Example #2
0
        public void AddMovie(Guid userId, string userName, Movie movie)
        {
            TinyMovie tinyMovie = (TinyMovie)movie;
            user_movie userMovie = Mapper.Map<TinyMovie, user_movie>(tinyMovie);
            userMovie.user_movie_user_id = userId;

            _userMovieRepo.Insert(userMovie);

            UserAction actionToAdd = new UserAction(userName, movie);
            actionToAdd.Action = Action.ADD_MOVIE;
            AddUserAction(actionToAdd);
        }