Exemple #1
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);
     }
 }
Exemple #2
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);
     }
 }
Exemple #3
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();
     }
 }
Exemple #4
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);
     }
 }
Exemple #5
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);
     }
 }
Exemple #6
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);
     }
 }