public Player GetByName(string PlayerName) { using (GameApiEntities ctx = new GameApiEntities()) { return(ctx.Player.Where(x => x.Nick.Contains(PlayerName)).FirstOrDefault()); } }
public List <Player> GetAll() { using (GameApiEntities ctx = new GameApiEntities()) { return(ctx.Player.ToList()); } }
public Room Get(int RoomId) { using (GameApiEntities ctx = new GameApiEntities()) { return(ctx.Room.Where(x => x.Id == RoomId).FirstOrDefault()); } }
public Player Get(int PlayerId) { using (GameApiEntities ctx = new GameApiEntities()) { return(ctx.Player.Where(x => x.Id == PlayerId).FirstOrDefault()); } }
public List <Room> GetAll() { using (GameApiEntities ctx = new GameApiEntities()) { return(ctx.Room.ToList()); } }
public List <Game> GetAll() { using (GameApiEntities ctx = new GameApiEntities()) { return(ctx.Game.ToList()); } }
public Game Get(int GameId) { using (GameApiEntities ctx = new GameApiEntities()) { return(ctx.Game.Where(x => x.Id == GameId).FirstOrDefault()); } }
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 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); } }
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); } }
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 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); } }