public MainForm(Models.GameModel model, Views.Table table) { InitializeComponent(); gameModel = model; tableView = table; model.AnswerGameStart += model_AnswerGameStart; }
public GameViewModel(Models.GameModel model) { this.model = model; this.PlayCommand = new RelayCommand(this.Play); // Copy fields from the model... this.Path = model.RelativePath; this.Ifid = model.Ifid; this.Format = model.Format; this.Bafn = model.Bafn; this.Title = model.Title; this.Author = model.Author; this.Language = model.Language; this.Headline = model.Headline; this.FirstPublished = model.FirstPublished; this.Genre = model.Genre; this.Group = model.Group; this.Description = model.Description; this.Series = model.Series; this.SeriesNumber = model.SeriesNumber; this.Forgiveness = model.Forgiveness; this.Url = model.Url; this.AuthorEmail = model.AuthorEmail; }
public GameViewModel(Models.GameModel model) { this.model = model; this.PlayCommand = new RelayCommand(this.Play); // Copy fields from the model... this.Path = model.RelativePath; this.Ifid = model.Ifid; this.Format = model.Format; this.Bafn = model.Bafn; this.Title = model.Title; this.Author = model.Author; this.Language = model.Language; this.Headline = model.Headline; this.FirstPublished = model.FirstPublished; this.Genre = model.Genre; this.Group = model.Group; this.Description = model.Description; this.Series = model.Series; this.SeriesNumber = model.SeriesNumber; this.Forgiveness = model.Forgiveness; this.Url = model.Url; this.AuthorEmail = model.AuthorEmail; }
public async Task <Models.GameModel> SearchGames(int appGameID) { try { DateTimeOffset _now = DateTimeOffset.Now; Game gameQuery = await _context.Games.Where(x => x.Id == appGameID).FirstAsync(); if (DateTimeOffset.Compare(gameQuery.EndDate, _now) > 0 && gameQuery.IsPublic == true) { Models.GameModel appGame = new Models.GameModel { Id = gameQuery.Id, GameName = gameQuery.GameName, OwnerId = gameQuery.OwnerId, StartDate = gameQuery.StartDate, EndDate = gameQuery.EndDate, TotalQuestions = gameQuery.TotalQuestions, IsPublic = gameQuery.IsPublic }; return(appGame); } else { throw new ArgumentException("No game exists."); } } catch (Exception e) { throw new Exception("Something Happened", e); } }
public async Task <GameModel> getAnyGame(int gameId) { try { DateTimeOffset _now = DateTimeOffset.Now; Game game = await _context.Games.Where(x => x.Id == gameId).FirstOrDefaultAsync(); if (game != null) { Models.GameModel appGame = new Models.GameModel { Id = game.Id, GameName = game.GameName, OwnerId = game.OwnerId, StartDate = game.StartDate, EndDate = game.EndDate, TotalQuestions = game.TotalQuestions, IsPublic = game.IsPublic }; return(appGame); } else { throw new ArgumentException("No game exists."); } } catch (Exception e) { throw new Exception("Something Happened", e); } }
public ActionResult <Models.GameModel> Update(Models.GameModel gameModel) { SQLDatabase database = new SQLDatabase(_connectionString); database.UpdateGame(gameModel); return(Ok(database.LoadGame(gameModel.GameId))); }
public ActionResult Create(int Players) { Carcassonne.Models.GameModel model = new Models.GameModel(); model.NumberOfPlayers = Players; model.Players = new List <Models.Player>(Players); return(PartialView("~/Views/Partials/EnterPlayers.cshtml", model)); }
public async Task <Models.GameModel> CreateGame(GameModel game) { Game newGame = new Game { GameName = game.GameName, OwnerId = game.OwnerId, StartDate = DateTime.Now, EndDate = game.EndDate, TotalQuestions = game.TotalQuestions, IsPublic = game.IsPublic }; await _context.AddAsync(newGame); await _context.SaveChangesAsync(); var owner = await _context.GamePlayers.ToListAsync(); var player = new GamePlayer { GameId = newGame.Id, PlayerId = game.OwnerId }; await _context.AddAsync(player); await _context.SaveChangesAsync(); Models.GameModel appGame = new Models.GameModel { Id = newGame.Id, GameName = newGame.GameName, OwnerId = newGame.OwnerId, StartDate = newGame.StartDate, EndDate = newGame.EndDate, TotalQuestions = newGame.TotalQuestions, IsPublic = newGame.IsPublic, PlayerId = game.PlayerId }; return(appGame); }
public async Task <Models.GameModel> CreateGame(int ownerId, string gameName, int totalQuestions, bool isPublic, double duration) { Game newGame = new Game { GameName = gameName, OwnerId = ownerId, StartDate = DateTime.Now, EndDate = DateTimeOffset.Now.AddMinutes(duration), TotalQuestions = totalQuestions, IsPublic = isPublic }; await _context.AddAsync(newGame); await _context.SaveChangesAsync(); var owner = await _context.GamePlayers.ToListAsync(); var player = new GamePlayer { GameId = newGame.Id, PlayerId = ownerId }; await _context.AddAsync(player); await _context.SaveChangesAsync(); Models.GameModel appGame = new Models.GameModel { Id = newGame.Id, GameName = newGame.GameName, OwnerId = newGame.OwnerId, StartDate = newGame.StartDate, EndDate = newGame.EndDate, TotalQuestions = newGame.TotalQuestions, IsPublic = newGame.IsPublic }; return(appGame); }
public async Task AddGame(Models.GameModel model) { var user = await _currentUser.GetCurrentUser(); // make sure games exists: var games = await GetGames(); int index = 0; if (games != null) { index = games.Length; } var firebaseClient = GetFirebaseClient(); await firebaseClient .Child("users") .Child(user.Uid) .Child("games") .Child(index.ToString()) .PutAsync(model); }