Example #1
0
 public int CreateUser(string name)
 {
     using (var ctx = new HighscoreContext())
     {
         var user = new User()
         {
             Name = name
         };
         var x = ctx.Users.Add(user);
         ctx.SaveChanges();
         return(x.ID);
     }
 }
Example #2
0
 public int CreateGame(string name)
 {
     using (var ctx = new HighscoreContext())
     {
         var game = new Game()
         {
             Name = name
         };
         var x = ctx.Games.Add(game);
         ctx.SaveChanges();
         return(x.ID);
     }
 }
Example #3
0
 public void CreateScore(int userId, int gameId, int points)
 {
     using (var ctx = new HighscoreContext())
     {
         User user = null;
         foreach (var u in ctx.Users.Where(s => s.ID == userId))
         {
             user = u;
         }
         Game game = null;
         foreach (var g in ctx.Games.Where(s => s.ID == gameId))
         {
             game = g;
         }
         var score = new Score()
         {
             User = user, Game = game, Points = points
         };
         var x = ctx.Scores.Add(score);
         ctx.SaveChanges();
     }
 }