示例#1
0
        public async Task <BoolContainer> AddMovieAsync(string movieName)
        {
            Movie movie;
            bool  result;

            //movie = imdbAPI.getMovie(movieName);
            movie = new Movie();
            GetImdbSeries getter = new GetImdbSeries();
            //Task<Episode> TEpisode = await getter.getSeries("hd");
            //Episode episode = await getter.getEpisode("hd");
            var episode = await getter.getEpisodeList(2);

            ////Episode episode = TEpisode.Result;
            //AddEpisodeToDatabase(episode);            // temp
            //getter.SetToken();

            if (movie.Response == "True")
            {
                AddMovieToDatabase(movie);
                result = true;
            }
            else
            {
                result = false;
            }

            return(new BoolContainer()
            {
                result = result
            });
        }
示例#2
0
        private async Task <List <Episode> > AddSeason(int seriesId, Database database)
        {
            List <Episode>  episodes;
            ResultContainer result = new ResultContainer();

            GetImdbSeries getter = new GetImdbSeries();

            episodes = await getter.getEpisodeList(seriesId);

            if (episodes.Count == 0)
            {
                result.result       = false;
                result.errorMessage = "No episodes found [Database.cs]";
                //return result;
            }

            //result.result = true;
            return(episodes);
        }
示例#3
0
        public async Task <ResultContainer> AddFolSeries(string seriesName)
        {
            Series          series;
            ResultContainer result = new ResultContainer();
            GetImdbSeries   getter = new GetImdbSeries();
            int             seriesId;

            // Searches API for seriesID
            seriesId = await getter.SearchForSeries(seriesName);

            if (seriesId == -1)
            {
                result.result       = false;
                result.errorMessage = "Series not found";
                return(result);
            }

            // Stops if series already is in database
            //if (CheckIfInDB(seriesId) == true)



            // Gets info about series
            series = await getter.GetSeries(seriesId);

            if (series.seriesName != null)
            {
                // Adds series to database
                AddSeriesToDatabase(series);
                // Adds the season to the database
                await AddSeason(series);

                result.result = true;
            }
            else
            {
                // Creates error message
                result.result       = false;
                result.errorMessage = "Series id not found";
            }

            return(result);
        }
示例#4
0
        public async Task <ResultContainer> AddSeries(string seriesName, Database database)
        {
            Series          series;
            ResultContainer result = new ResultContainer();
            GetImdbSeries   getter = new GetImdbSeries();
            int             seriesId;

            // Searches API for seriesID
            seriesId = await getter.SearchForSeries(seriesName);

            if (seriesId == -1)
            {
                result.result       = false;
                result.errorMessage = "Series not found";
                return(result);
            }

            // Check if it's already added
            if (CheckIfSeriesIsInDB(seriesId))
            {
                result.result       = false;
                result.errorMessage = "Already added";
                return(result);
            }

            // Gets series
            series = await getter.GetSeries(seriesId);

            if (series.seriesName != null)
            {
                result = await addAllSeriesEpisodes(series);
            }
            else
            {
                // Creates error message
                result.result       = false;
                result.errorMessage = "Series id not found";
            }

            return(result);
        }
示例#5
0
        public async Task <ResultContainer> AddSeason(Series series)
        {
            List <Episode>  episodes;
            ResultContainer result = new ResultContainer();

            GetImdbSeries getter = new GetImdbSeries();

            episodes = await getter.getEpisodeList(2);

            if (episodes.Count == 0)
            {
                result.result       = false;
                result.errorMessage = "No episodes found [Database.cs]";
                return(result);
            }

            foreach (Episode episode in episodes)
            {
                AddEpisodeToDatabase(episode);
            }

            result.result = true;
            return(result);
        }