示例#1
0
        public async static Task RemoveMovies(List <Movie> toRemove, string UID, Client socket)
        {
            FileHandler handler = new FileHandler();

            handler.removeMovies(toRemove);
            await MongoInteraction.RemoveMovies(toRemove, socket);
        }
示例#2
0
        /// <summary>
        /// Use to make sure the user files are in line.
        /// </summary>
        /// <param name="UID"></param>
        public async static Task SyncUserFiles(string UID, Client socket, FileHandler.platformType platform = FileHandler.platformType.Windows)
        {
            List <Movie> listOfMoviesDB = await MongoInteraction.AllMoviesByUser(UID, socket);

            FileHandler  tmpFileHandler  = new FileHandler(platform);
            List <Movie> listOfMoviesXML = tmpFileHandler.allMoviesInXml();

            //The user has no entries on the DB
            if (listOfMoviesDB.Count == 0)
            {
                if (listOfMoviesXML.Count == 0)
                {
                    //The user doesn't have any movies in their XML either.
                    return;
                }

                else
                {
                    await AddMoviesDB(listOfMoviesXML, UID, socket);
                }
            }

            //The user has no entries in their XML
            else if (listOfMoviesXML.Count == 0)
            {
                if (listOfMoviesDB.Count == 0)
                {
                    //The user doesn't have any movies in their DB.
                    return;
                }

                else
                {
                    TMDBHelper   helper  = new TMDBHelper();
                    FileHandler  handler = new FileHandler(platform);
                    List <Movie> toAdd   = new List <Movie>();

                    handler.addMovies(listOfMoviesDB);
                }
            }

            else
            {
                List <Movie> dbBalance = FindDifferences(listOfMoviesDB, listOfMoviesXML);
                if (dbBalance.Count != 0)
                {
                    await AddMoviesDB(dbBalance, UID, socket);
                }

                List <Movie> xmlBalance = FindDifferences(listOfMoviesXML, listOfMoviesDB);
                if (xmlBalance.Count != 0)
                {
                    AddMoviesXML(xmlBalance, platform);
                }
            }
        }
示例#3
0
 /// <summary>
 /// Add a collection of movies
 /// </summary>
 /// <param name="listOfMoviesXML"></param>
 /// <param name="UID"></param>
 private async static Task AddMoviesDB(List <Movie> listOfMoviesXML, string UID, Client socket)
 {
     await MongoInteraction.AddMovies(UID, listOfMoviesXML, socket);
 }