コード例 #1
0
ファイル: PlayerDAL.cs プロジェクト: marekdab/GameWithApi
 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);
     }
 }
コード例 #2
0
ファイル: RoomDAL.cs プロジェクト: marekdab/GameWithApi
 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);
     }
 }
コード例 #3
0
ファイル: PlayerDAL.cs プロジェクト: marekdab/GameWithApi
 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();
     }
 }
コード例 #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);
     }
 }
コード例 #5
0
ファイル: RoomDAL.cs プロジェクト: marekdab/GameWithApi
 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);
     }
 }
コード例 #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);
     }
 }