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); } }
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); } }
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(); } }
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); } }
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); } }
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); } }