Exemple #1
0
        private static void Main(string[] args)
        {
            DataManager dataManager = new DataManager();

            dataManager.CheckIfFolderExists();

            Games        games       = new Games();
            List <Games> gameLibrary = new List <Games>();

            dataManager.CheckIfDataFileExists(gameLibrary, dataManager.pathGamesDataFile, games.Properties());

            List <Users> userList = new List <Users>();
            Users        user     = new Users();

            dataManager.CheckIfDataFileExists(userList, dataManager.pathUsersDataFile, user.Properties());

            LoginMenu login = new LoginMenu();

            login.ShowLoginMenu(gameLibrary, userList);
        }
Exemple #2
0
        private void SelectInMenu(List <Games> gameLibrary, List <Users> userList)
        {
            Games          games = new Games();
            ConsoleKeyInfo option;

            option = Console.ReadKey(true);

            switch (option.Key)
            {
            case ConsoleKey.NumPad1:

                ShowLibrary(gameLibrary, userList);
                break;

            case ConsoleKey.NumPad2:
                AddNewGame(gameLibrary, userList);
                break;

            case ConsoleKey.NumPad3:
                SelectDeleteGame(gameLibrary, userList);
                break;

            case ConsoleKey.NumPad4:
                ShowUsersMenu(gameLibrary, userList);
                break;

            case ConsoleKey.NumPad5:
                dataManager.WriteDataFile(gameLibrary, dataManager.pathGamesDataFile, games.Properties());
                LoginMenu login = new LoginMenu();
                login.ShowLoginMenu(gameLibrary, userList);
                break;

            default:
                Console.WriteLine("Choose one of the Options");
                SelectInMenu(gameLibrary, userList);
                break;
            }
        }
        public void CreateUser(List <Users> userList)
        {
            Console.Write("Username:"******"Email:");
            string email = Console.ReadLine();

            Console.Write("Country:");
            string country = Console.ReadLine();

            Console.Write("Real Name:");
            string realname = Console.ReadLine();

            Console.Write("Age:");
            int age = Convert.ToInt32(Console.ReadLine());

            List <Games> userLibrary = new List <Games>();
            Users        user        = new Users(username, realname, email, country, age, userLibrary);

            userList.Add(user);
            DataManager dataManager = new DataManager();

            dataManager.WriteDataFile(userList, dataManager.pathUsersDataFile, user.Properties());
            Games games = new Games();

            dataManager.WriteDataFile(user.Library, dataManager.pathUsersLibraryDataFile(user.Username), games.Properties());
        }
 public void UpdateUserLibrary(Users user, Games game)
 {
     if (AddingGame == true)
     {
         user.Library.Add(game);
         DataManager dataManager = new DataManager();
         Games       games       = new Games();
         dataManager.WriteDataFile(user.Library, dataManager.pathUsersLibraryDataFile(user.Username), games.Properties());
     }
     else if (AddingGame == false)
     {
         user.Library.Remove(game);
         DataManager dataManager = new DataManager();
         Games       games       = new Games();
         dataManager.WriteDataFile(user.Library, dataManager.pathUsersLibraryDataFile(user.Username), games.Properties());
     }
 }