Esempio n. 1
0
 public Player GetByName(string PlayerName)
 {
     using (GameApiEntities ctx = new GameApiEntities())
     {
         return(ctx.Player.Where(x => x.Nick.Contains(PlayerName)).FirstOrDefault());
     }
 }
Esempio n. 2
0
 public List <Player> GetAll()
 {
     using (GameApiEntities ctx = new GameApiEntities())
     {
         return(ctx.Player.ToList());
     }
 }
Esempio n. 3
0
 public Room Get(int RoomId)
 {
     using (GameApiEntities ctx = new GameApiEntities())
     {
         return(ctx.Room.Where(x => x.Id == RoomId).FirstOrDefault());
     }
 }
Esempio n. 4
0
 public Player Get(int PlayerId)
 {
     using (GameApiEntities ctx = new GameApiEntities())
     {
         return(ctx.Player.Where(x => x.Id == PlayerId).FirstOrDefault());
     }
 }
Esempio n. 5
0
 public List <Room> GetAll()
 {
     using (GameApiEntities ctx = new GameApiEntities())
     {
         return(ctx.Room.ToList());
     }
 }
Esempio n. 6
0
 public List <Game> GetAll()
 {
     using (GameApiEntities ctx = new GameApiEntities())
     {
         return(ctx.Game.ToList());
     }
 }
Esempio n. 7
0
 public Game Get(int GameId)
 {
     using (GameApiEntities ctx = new GameApiEntities())
     {
         return(ctx.Game.Where(x => x.Id == GameId).FirstOrDefault());
     }
 }
Esempio n. 8
0
 public void Delete(int id)
 {
     using (GameApiEntities ctx = new GameApiEntities())
     {
         var ic = ctx.Player.Where(x => x.Id == id).FirstOrDefault();
         ctx.Player.Remove(ic);
         ctx.SaveChanges();
     }
 }
Esempio n. 9
0
 public Player Update(Player model)
 {
     using (GameApiEntities ctx = new GameApiEntities())
     {
         var ic = ctx.Player.Where(x => x.Id == model.Id).FirstOrDefault();
         ic.Nick = model.Nick;
         ic.Room = model.Room;
         ctx.SaveChanges();
         return(model);
     }
 }
Esempio n. 10
0
 public Room Update(Room model)
 {
     using (GameApiEntities ctx = new GameApiEntities())
     {
         var ic = ctx.Room.Where(x => x.Id == model.Id).FirstOrDefault();
         ic.CreatorId = model.CreatorId;
         ic.Name      = model.Name;
         ic.Password  = model.Password;
         ctx.SaveChanges();
         return(model);
     }
 }
Esempio n. 11
0
 public Game Update(Game model)
 {
     using (GameApiEntities ctx = new GameApiEntities())
     {
         var ic = ctx.Game.Where(x => x.Id == model.Id).FirstOrDefault();
         ic.Name        = model.Name;
         ic.Password    = model.Password;
         ic.Room        = model.Room;
         ic.Description = model.Description;
         ctx.SaveChanges();
         return(model);
     }
 }
Esempio n. 12
0
 public Player Add(Player model)
 {
     using (GameApiEntities ctx = new GameApiEntities())
     {
         var m = ctx.Player.Add(new Player()
         {
             Nick = model.Nick
         });                //tu dodajemy model
         ctx.SaveChanges(); //tu zapisujemy zmiany
         model.Id = m.Id;
         ctx.SaveChanges();
         return(model);
     }
 }
Esempio n. 13
0
 public Room Add(Room model)
 {
     using (GameApiEntities ctx = new GameApiEntities())
     {
         var m = ctx.Room.Add(new Room()
         {
             Name      = model.Name,
             Password  = model.Password,
             CreatorId = model.CreatorId
         });                //tu dodajemy model
         ctx.SaveChanges(); //tu zapisujemy zmiany
         model.Id = m.Id;
         ctx.SaveChanges();
         return(model);
     }
 }
Esempio n. 14
0
 public Game Add(Game model)
 {
     using (GameApiEntities ctx = new GameApiEntities())
     {
         var m = ctx.Game.Add(new Game()
         {
             Name        = model.Name,
             Password    = model.Password,
             Time        = model.Time,
             Room        = model.Room,
             Description = model.Description
         });                //tu dodajemy model
         ctx.SaveChanges(); //tu zapisujemy zmiany
         model.Id = m.Id;
         ctx.SaveChanges();
         return(model);
     }
 }