Exemplo n.º 1
0
 public static void DeleteGameByName(string gameName)
 {
     using (var dbCtx = new GrafilogikaDBEntities())
     {
         try
         {
             var result = (from g in dbCtx.Games
                           where g.Name == gameName
                           select g).First();
             dbCtx.Games.Remove(result);
             dbCtx.SaveChanges();
         }
         catch (Exception)
         {
             throw;
         }
     }
 }
Exemplo n.º 2
0
        public static void AddUser(string name, string pw, int isadmin, string email, int isverified)
        {
            Users addThis = new Users();

            using (var dbCtx = new GrafilogikaDBEntities())
            {
                addThis.Name = name;
                addThis.Password = pw;
                addThis.Wins = 0;
                addThis.Mistakes = 0;
                addThis.Isadmin = isadmin;
                addThis.Email = email;
                addThis.Isverified = isverified;
                dbCtx.Users.Add(addThis);

                dbCtx.SaveChanges();
            }
        }
Exemplo n.º 3
0
        public static void AddGame(string name, string uploader, string game)
        {
            Games addThis = new Games();

            using (var dbCtx = new GrafilogikaDBEntities())
            {
                try
                {
                    addThis.Name = name;
                    addThis.Uploader = uploader;
                    addThis.Wins = 0;
                    addThis.Rating = 0;
                    addThis.Mistakes = 0;
                    addThis.Game = game;
                    dbCtx.Games.Add(addThis);

                    dbCtx.SaveChanges();
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.StackTrace);
                }
            }
        }
Exemplo n.º 4
0
        public static void UpdateUserWins(Users usr)
        {
            using (var dbCtx = new GrafilogikaDBEntities())
            {
                try
                {
                    if (usr.Wins == null)
                    {
                        usr.Wins = 0;
                    }
                    usr.Wins++;
                    dbCtx.Entry(usr).State = EntityState.Modified;
                    dbCtx.SaveChanges();
                }
                catch (Exception)
                {

                    throw;
                }
            }
        }
Exemplo n.º 5
0
 public static void UpdateUserVerification(string userName)
 {
     try
     {
         using (var dbCtx = new GrafilogikaDBEntities())
         {
             var result = (from u in dbCtx.Users
                           where u.Name == userName
                           select u).First();
             result.Isverified++;
             dbCtx.Entry(result).State = EntityState.Modified;
             dbCtx.SaveChanges();
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
Exemplo n.º 6
0
 public static void UpdateUserAdmin(string userName)
 {
     try
     {
         using (var dbCtx = new GrafilogikaDBEntities())
         {
             var result = (from u in dbCtx.Users
                           where u.Name == userName
                           select u).First();
             if (result.Isadmin == 1)
             {
                 result.Isadmin = 0;
             }
             else if (result.Isadmin == 0)
             {
                 result.Isadmin = 1;
             }
             dbCtx.Entry(result).State = EntityState.Modified;
             dbCtx.SaveChanges();
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
Exemplo n.º 7
0
        public static void UpdateGameWins(Games game)
        {
            using (var dbCtx = new GrafilogikaDBEntities())
            {
                try
                {
                    if (game.Wins == null)
                    {
                        game.Wins = 0;
                    }
                    game.Wins++;
                    dbCtx.Entry(game).State = EntityState.Modified;
                    dbCtx.SaveChanges();
                }
                catch (Exception)
                {

                    throw;
                }
            }
        }
Exemplo n.º 8
0
        public static void UpdateGameRating(Games game, int rating)
        {
            using (var dbCtx = new GrafilogikaDBEntities())
            {
                try
                {
                    if (game.Rating == null || game.Rating == 0)
                    {
                        game.Rating = rating;
                    }
                    else
                    {
                        game.Rating += rating;
                    }
                    dbCtx.Entry(game).State = EntityState.Modified;
                    dbCtx.SaveChanges();
                }
                catch (Exception)
                {

                    throw;
                }
            }
        }