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