Esempio n. 1
0
 public void DeleteDatabase()
 {
     using (var context = new DatabaseORM())
     {
         context.Database.Delete();
     }
 }
Esempio n. 2
0
 public bool DeleteUser(string username)
 {
     using (var context = new DatabaseORM())
     {
         UserEntity           user           = null;
         UserStatisticsEntity userStatistics = null;
         foreach (UserEntity u in context.Users)
         {
             if (u.Username.Equals(username))
             {
                 user = u;
             }
         }
         foreach (UserStatisticsEntity us in context.UserStatistics)
         {
             if (us.Username.Equals(username))
             {
                 userStatistics = us;
             }
         }
         if (user != null && userStatistics != null)
         {
             context.Users.Remove(user);
             context.SaveChanges();
             context.UserStatistics.Remove(userStatistics);
             context.SaveChanges();
             return(true);
         }
     }
     return(false);
 }
Esempio n. 3
0
 public UserStatisticsEntity GetUserStats(string username)
 {
     using (var context = new DatabaseORM())
     {
         UserStatisticsEntity userstats = context.UserStatistics.Find(username);
         return(userstats);
     }
 }
Esempio n. 4
0
 public void DeleteAllData()
 {
     using (var context = new DatabaseORM())
     {
         context.UserStatistics.RemoveRange(context.UserStatistics);
         context.Users.RemoveRange(context.Users);
         context.GameLogs.RemoveRange(context.GameLogs);
         context.SaveChanges();
     }
 }
Esempio n. 5
0
 public bool AddGameLog(int gameID, string serial)
 {
     using (var context = new DatabaseORM())
     {
         context.GameLogs.Add(new GamelogsEntity()
         {
             GameID = gameID, GameLogSerial = serial
         });
         context.SaveChanges();
         return(true);
     }
 }
Esempio n. 6
0
        public List <GamelogsEntity> GetListOfGameLogs()
        {
            var gameLogsList = new List <GamelogsEntity>();

            using (var context = new DatabaseORM())
            {
                foreach (GamelogsEntity gl in context.GameLogs)
                {
                    gameLogsList.Add(gl);
                }
            }
            return(gameLogsList);
        }
Esempio n. 7
0
        public List <UserStatisticsEntity> GetAllUserStatistics()
        {
            var userStats = new List <UserStatisticsEntity>();

            using (var context = new DatabaseORM())
            {
                foreach (UserStatisticsEntity us in context.UserStatistics)
                {
                    userStats.Add(us);
                }
            }
            return(userStats);
        }
Esempio n. 8
0
        public List <UserEntity> GetRegisteredUsers()
        {
            var users = new List <UserEntity>();

            using (var context = new DatabaseORM())
            {
                foreach (UserEntity u in context.Users)
                {
                    users.Add(u);
                }
            }
            return(users);
        }
Esempio n. 9
0
 public GamelogsEntity GetGameLog(int gameID)
 {
     using (var context = new DatabaseORM())
     {
         foreach (GamelogsEntity gl in context.GameLogs)
         {
             Console.WriteLine(gl.GameID);
             if (gl.GameID == gameID)
             {
                 return(gl);
             }
         }
     }
     return(null);
 }
Esempio n. 10
0
 public bool DeleteGameLog(int gameID)
 {
     using (var context = new DatabaseORM())
     {
         GamelogsEntity gl = context.GameLogs.Single(gamelog => gamelog.GameID == gameID);
         if (gl != null)
         {
             context.GameLogs.Remove(gl);
             context.SaveChanges();
             return(true);
         }
         Console.WriteLine("it was null????");
     }
     return(false);
 }
Esempio n. 11
0
        public UserEntity GetUser(string username)
        {
            UserEntity user = new UserEntity();

            using (var context = new DatabaseORM())
            {
                foreach (UserEntity u in context.Users)
                {
                    if (u.Username.Equals(username))
                    {
                        user = u;
                        return(user);
                    }
                }
            }
            return(null);
        }
Esempio n. 12
0
        public bool UpdateUserLeague(string username, int newLeagueID)
        {
            using (var context = new DatabaseORM())
            {
                UserEntity updatedUser = new UserEntity();

                var original = context.Users.Find(username);

                if (original != null)
                {
                    updatedUser.Username = original.Username;
                    updatedUser.Password = original.Password;
                    updatedUser.Email    = original.Email;
                    updatedUser.Money    = original.Money;
                    updatedUser.LeagueId = newLeagueID;
                    context.Entry(original).CurrentValues.SetValues(updatedUser);
                    context.SaveChanges();
                    return(true);
                }
            }
            return(false);
        }
Esempio n. 13
0
        public bool EditUser(string username, string password, string email, int money)
        {
            using (var context = new DatabaseORM())
            {
                UserEntity updatedUser = new UserEntity();

                var original = context.Users.Find(username);

                if (original != null)
                {
                    updatedUser.Username = username;
                    updatedUser.Password = password;
                    updatedUser.Email    = email;
                    updatedUser.Money    = money;
                    updatedUser.LeagueId = original.LeagueId;
                    context.Entry(original).CurrentValues.SetValues(updatedUser);
                    context.SaveChanges();
                    return(true);
                }
            }
            return(false);
        }
Esempio n. 14
0
        public bool AddUser(string username, string password, string email, int money, int leagueID)
        {
            using (var context = new DatabaseORM())
            {
                context.Users.Add(new UserEntity()
                {
                    Username = username, Password = password, Email = email, Money = money, LeagueId = leagueID
                });

                context.UserStatistics.Add(new UserStatisticsEntity()
                {
                    Username         = username,
                    AvgCashGain      = 0,
                    AvgGrossProfit   = 0,
                    HighestCashGain  = 0,
                    NumOfGames       = 0,
                    Points           = 0,
                    TotalGrossProfit = 0
                });
                context.SaveChanges();
            }
            return(true);
        }
Esempio n. 15
0
        public bool UpdateUserStats(string username, int points, int numOfGames, int totalGrossProfit, int highestCashGain, int avgGrossProfit, int avgCashGain)
        {
            using (var context = new DatabaseORM())
            {
                UserStatisticsEntity updatedUserStats = new UserStatisticsEntity();

                var original = context.UserStatistics.Find(username);

                if (original != null)
                {
                    updatedUserStats.Username         = username;
                    updatedUserStats.Points           = points;
                    updatedUserStats.NumOfGames       = numOfGames;
                    updatedUserStats.TotalGrossProfit = totalGrossProfit;
                    updatedUserStats.HighestCashGain  = highestCashGain;
                    updatedUserStats.AvgGrossProfit   = avgGrossProfit;
                    updatedUserStats.AvgCashGain      = avgCashGain;
                    context.Entry(original).CurrentValues.SetValues(updatedUserStats);
                    context.SaveChanges();
                    return(true);
                }
            }
            return(false);
        }