public GameDescriptor PutOneGame([FromBody] GameDescriptor descriptor) { GameDescriptor validatedDescriptor = new GameDescriptor(descriptor); lobbyHub.Clients.All.SendAsync("InformGameCreated", validatedDescriptor); return(GameAccessor.SaveGame(validatedDescriptor).Result); }
public static bool ApproveGame(int gameId) { bool result = false; try { var game = RetrieveGame(gameId); if (!string.IsNullOrEmpty(game.Publisher)) { PublisherManager.ApprovePublisher(game.Publisher); } if (!string.IsNullOrEmpty(game.Developer)) { DeveloperManager.ApproveDeveloper(game.Developer); } if (!string.IsNullOrEmpty(game.Console)) { ConsoleManager.ApproveConsole(game.Console); } GameAccessor.ApproveGame(gameId); } catch (Exception) { throw; } return(result); }
public async Task RequestGameCreation(GameDescriptor descriptor) { GameDescriptor validatedDescriptor = new GameDescriptor(descriptor); await Task.WhenAll( GameAccessor.SaveGame(validatedDescriptor), InformGameCreated(validatedDescriptor)); }
public void Run() { var games = new GameAccessor().GetAll(); var db = new PlayAccessor(); var csv = File.ReadAllLines("GameList.tsv"); for (int i = 1; i < csv.Length; i++) { var line = csv[i]; var cells = line.Split('\t'); var play = new PlayEntity(); play.Date = new DateTime(2014, 12, 31); play.Duration = TimeSpan.FromHours(double.Parse(cells[3], CultureInfo.InvariantCulture)); play.GameId = games.First(p => p.Name == cells[0]).Id; play.PlayerCount = 2; var numberOfOldPlays = int.Parse(cells[2]); for (int x = 0; x < numberOfOldPlays; x++) { db.Create(play); play.Id = Guid.Empty; } } }
public void Run() { var db = new GameAccessor(); var csv = File.ReadAllLines("GameList.csv"); for (int i = 1; i < csv.Length; i++) { var line = csv[i]; var cells = line.Split(','); var game = new GameEntity(); game.Name = cells[0]; game.SoloMode = GetSoloMode(cells[4]); game.WantToSell = GetBool(cells[5]); game.IsGenuine = GetBool(cells[6]); game.IsDelivered = GetBool(cells[7]); game.PurchasePrice = double.Parse(cells[8]); game.SellPrice = string.IsNullOrEmpty(cells[9]) ? 0 : double.Parse(cells[9]); game.Rating = string.IsNullOrEmpty(cells[10]) ? 0 : int.Parse(cells[10]); game.DesireToPlay = string.IsNullOrEmpty(cells[11]) ? 0 : int.Parse(cells[11]); db.Create(game); } }
public void Run() { var games = new GameAccessor().GetAll(); var db = new PlayAccessor(); var tsv = File.ReadAllLines($"{_year}.tsv"); for (int i = 1; i < tsv.Length; i++) { var line = tsv[i]; var cells = line.Split('\t'); var play = new PlayEntity(); play.Date = DateTime.Parse(cells[0]); play.Duration = TimeSpan.FromHours(double.Parse(cells[2], CultureInfo.InvariantCulture)); var game = games.FirstOrDefault(p => p.Name == cells[1]); if (game == null) { Console.WriteLine($"Couldn't find game {cells[1]}."); continue; } play.GameId = game.Id; play.Comment = cells.Length == 4 ? cells[3] : null; play.PlayerCount = game.SoloMode == SoloMode.None ? 2 : 1; db.Create(play); } }
public bool EditGame(Game oldGame, Game newGame) { try { return(GameAccessor.UpdateGame(oldGame, newGame) == 1); } catch (Exception) { return(false); } }
public bool CreateGame(Game game) { try { return(GameAccessor.InsertGame(game) == 1); } catch (Exception) { return(false); } }
public List <Game> RetrieveGamesForRental() { try { games = GameAccessor.RetrieveAllGames(); } catch (Exception) { } return(games); }
public List <Game> RetrieveSupplierGamesStock(int supplierId) { try { games = GameAccessor.RetrieveGamesFromSupplier(supplierId); } catch (Exception) { throw; } return(games); }
public List <Game> RetrieveGamesInKiosk(int kioskId, int adminId) { try { games = GameAccessor.RetrieveGamesByKioskIdAndAdminId(kioskId, adminId); } catch (Exception) { throw; } return(games); }
public List <Game> RetrieveGamesByMediumId(string mediumId) { try { games = GameAccessor.RetrieveGamesByMediumType(mediumId); } catch (Exception) { throw; } return(games); }
public List <Game> RetrieveGamesByGenreID(string genreId) { try { games = GameAccessor.RetrieveGamesByGenre(genreId); } catch (Exception) { throw; } return(games); }
public List <Game> RetrieveGamesWithGenreAndMediumFilter(string genreId, string mediumId) { try { games = GameAccessor.RetrieveGamesByGenreAndMedium(genreId, mediumId); } catch (Exception) { throw; } return(games); }
public static List <Game> RetrieveUserGames(string username) { List <Game> games = null; try { games = GameAccessor.RetrieveUserGames(username); } catch (Exception) { throw; } return(games); }
public static Game RetrieveGame(int gameId) { Game game = null; try { game = GameAccessor.RetrieveGame(gameId); } catch (Exception) { throw; } return(game); }
//Also replace this with a better stored procedure if time permits. public static bool CheckUserGame(int gameId, string username) { bool result = false; try { result = 1 == GameAccessor.VerifyUserGame(gameId, username); } catch (Exception) { throw; } return(result); }
public static List <Game> RetrieveGames(bool active = true) { List <Game> games = null; try { games = GameAccessor.RetrieveGames(active); } catch (Exception) { throw; } return(games); }
public static bool UpdateUserGames(string username, List <Game> gamesToSet) { bool result = true; foreach (var game in gamesToSet) { if (game.IsOwned) { GameAccessor.CreateUserGame(game.Id, username); } else { GameAccessor.DeleteUserGame(game.Id, username); } } return(result); }
public static bool DeleteGame(int gameId) { bool result = false; try { var game = GameAccessor.RetrieveGame(gameId); GameAccessor.DeleteGame(gameId); ConsoleManager.VerifyConsole(game.Console); DeveloperManager.VerifyDeveloper(game.Developer); PublisherManager.VerifyPublisher(game.Publisher); } catch { throw; } return(result); }
public static bool CreateGame(Game game, string username = null, bool admin = false) { bool result = false; try { if (!string.IsNullOrEmpty(game.Publisher) && !PublisherManager.RetrievePublishers().Contains(game.Publisher.Trim())) { if (!PublisherManager.CreatePublisher(game.Publisher, admin)) { throw new ApplicationException("Publisher failed to write!"); } } if (!string.IsNullOrEmpty(game.Developer) && !DeveloperManager.RetrieveDevelopers().Contains(game.Developer.Trim())) { if (!DeveloperManager.CreateDeveloper(game.Developer, admin)) { throw new ApplicationException("Developer failed to write!"); } } if (!string.IsNullOrEmpty(game.Console) && !ConsoleManager.RetrieveConsoles().Contains(game.Console.Trim())) { if (!ConsoleManager.CreateConsole(game.Console, admin)) { throw new ApplicationException("Console failed to write!"); } } int gameId = GameAccessor.CreateGame(game, admin); //If an admin called this with the admin parameter, don't add it to their collection. if (username != null && admin == false) { GameAccessor.CreateUserGame(gameId, username); } } catch (Exception) { throw; } return(result); }
public bool RemoveGamesFromKiosk(int gameId) { bool result = false; try { if (1 == GameAccessor.DeactivateGamesInKiosk(gameId, 1, 0)) { result = true; } else { result = false; } } catch (Exception) { } return(result); }
public bool AddGamesToKiosk(int gameId) { bool result = false; try { if (1 == GameAccessor.ActivateGames(gameId, 0, 1)) { result = true; } else { result = false; } } catch (Exception) { } return(result); }
public static bool ToggleUserGame(int gameId, string username) { bool result = false; try { bool created = 1 == GameAccessor.CreateUserGame(gameId, username); if (created) { result = created; } else { result = 1 == GameAccessor.DeleteUserGame(gameId, username); } } catch (Exception) { throw; } return(result); }
public static bool UpdateGame(Game oldGame, Game newGame) { bool result = false; try { if (GameAccessor.RetrieveGame(oldGame.Id) != oldGame) { throw new ApplicationException("Game has been updated since last retrieval!"); } else { if (!DeveloperManager.UpdateDeveloper(newGame.Developer)) { throw new ApplicationException("Developer failed to update!"); } if (!ConsoleManager.UpdateConsole(newGame.Console)) { throw new ApplicationException("Console failed to update!"); } if (!PublisherManager.UpdatePublisher(newGame.Publisher)) { throw new ApplicationException("Publisher failed to update!"); } result = 1 == GameAccessor.UpdateGame(oldGame, newGame); ConsoleManager.VerifyConsole(oldGame.Console); DeveloperManager.VerifyDeveloper(oldGame.Developer); PublisherManager.VerifyPublisher(oldGame.Publisher); } } catch { throw; } return(result); }
public IEnumerable <GameDescriptor> GetAllGames() { return(GameAccessor.GetAllGames()); }
public GameDescriptor GetOneGame(Guid id) { return(GameAccessor.GetOneGame(id)); }