public TigerGame Add(TigerGame newGame) { _context.Games.Add(newGame); _context.SaveChanges(); return(newGame); }
public UserGame Add(User user, TigerGame game) { var selectedUser = _context.Users.Where(u => u.UserName == user.UserName).FirstOrDefault(); var selectedGame = _context.Games.Where(g => g.GameName == game.GameName).FirstOrDefault(); if (selectedUser != null && selectedGame != null) { try { var newUserGame = new UserGame { UserID = selectedUser.Id, GameID = selectedGame.Id }; _context.UserGames.Add(newUserGame); _context.SaveChanges(); return(newUserGame); }catch (Exception ex) { Console.WriteLine($"{ex.Source}: {ex.Message}"); } } return(null); }
public async Task <bool> UserGameExists(SocketGuildUser y) { var newUser = new User { UserName = y.Mention }; var newGame = new TigerGame { GameName = y.Game.ToString() }; var ExistingUser = _users.Get(newUser); var ExistingGame = _games.Get(newGame); if (ExistingUser == null) { throw new UserNotFoundException("User not found!"); } if (ExistingGame == null) { throw new GameNotFoundException("Game not found!"); } if (_ug.Get(ExistingUser, ExistingGame) is null) { return(false); } return(true); }
private async Task AddUserGame(SocketGuildUser y) { try { // Create an ad-hoc user and game var newUser = new User { UserName = y.Mention }; var newGame = new TigerGame { GameName = y.Game.ToString() }; // get the actual user and game. These values have to be present in order to make the game. var user = _users.Get(newUser); var game = _games.Get(newGame); if (user == null) { throw new UserNotFoundException($"{newUser.UserName} not found."); } if (game == null) { throw new GameNotFoundException($"{newGame.GameName} not found."); } _ug.Add(user, game); await Log(CreateLogMessage(LogSeverity.Info, "Add usergame to usergame table", $"Added {newUser.UserName}, {newGame.GameName}.")); } catch (Exception ex) { await Log(CreateLogMessage(LogSeverity.Critical, $"{ex.Source}", $"Exception: {ex.Message}")); } }
private TigerGame CreateNewGame(string gameName) { var newGame = new TigerGame { GameName = gameName }; return(newGame); }
private bool CheckUserGameExists(TigerGame game, User user) { var selectedUserGame = _userGames.Get(user, game); if (selectedUserGame == null) { return(false); } return(true); }
private bool CheckGameExists(TigerGame game) { var selectedGame = _games.Get(game); if (selectedGame == null) { return(false); } return(true); }
public async Task <bool> GameExists(SocketGuildUser game) { var newGame = new TigerGame { GameName = game.Game.ToString() }; if (_games.Get(newGame) != null) { return(true); } return(false); }
public IQueryable <UserGame> GetGameUsersLoose(TigerGame game) { var selectedGame = _context.Games.Where(g => g.GameName.Contains(game.GameName)).FirstOrDefault(); if (selectedGame != null) { var newUserGame = new UserGame { GameID = selectedGame.Id }; return(_context.UserGames.Where(ug => ug.GameID == newUserGame.GameID).OrderBy(ug => ug.GameID == newUserGame.GameID)); } return(null); }
private async Task AddGameToGameTable(SocketGuildUser game) { try { var newGame = new TigerGame { GameName = game.Game.ToString() }; _games.Add(newGame); await Log(CreateLogMessage(LogSeverity.Info, "Add game to game table", $"Added {newGame.GameName}")); } catch (Exception ex) { await Log(CreateLogMessage(LogSeverity.Critical, $"{ex.Source}", $"Exception: {ex.Message}")); } }
public TigerGame Update(TigerGame game) { throw new NotImplementedException(); }
public TigerGame GetGameById(TigerGame game) { return(_context.Games.FirstOrDefault(g => g.Id == game.Id)); }
public TigerGame Get(TigerGame game) { return(_context.Games.FirstOrDefault(g => g.GameName.Equals(game.GameName))); }