public IEnumerator insertGame() { UnityWebRequest httpClient = new UnityWebRequest(player.HttpServerAdrees + "api/Games/InsertGame", "POST"); GamesModel newGame = new GamesModel(); newGame.PlayerName = player.Name; int now = int.Parse(DateTime.Now.ToString("yyyyMMdd")); int birthdate = int.Parse(player.DateBirth.ToString("yyyyMMdd")); int age = (now - birthdate) / 1000; newGame.Age = age.ToString(); newGame.HourGame = DateTime.Now.ToString(); newGame.Score = score.ToString(); string jsonData = JsonUtility.ToJson(newGame); byte[] dataToSend = Encoding.UTF8.GetBytes(jsonData); httpClient.uploadHandler = new UploadHandlerRaw(dataToSend); httpClient.SetRequestHeader("Authorization", "bearer " + player.Token); httpClient.SetRequestHeader("Content-Type", "application/json"); httpClient.certificateHandler = new ByPassCertificate(); yield return(httpClient.SendWebRequest()); if (httpClient.isNetworkError || httpClient.isHttpError) { throw new Exception("OnRegisterButtonClick: Error > " + httpClient.error); } httpClient.Dispose(); }
public ActionResult Display(int id) { var game = _gameRepository.GetQuery() .Include("Comments") .First(g => g.ID == id); var Comments = game.Comments .Where(c => c.IsApproved) .Select(c => new CommentModel() { CommentText = c.CommentText, AnonymousName = c.AnonymousName, DateCreated = c.DateCreated, Email = c.Email, Website = c.Website }); var gameModel = new GamesModel() { ID = game.ID, Name = game.Name, HtmlContent = game.HtmlContent.ToHtmlDecode() }; gameModel.Comments = Comments; return(View(gameModel)); }
public async Task <IActionResult> Edit(int id, [Bind("ID,Name,Genre,GameStatus,PremiereDate,DeveloperID,Hltb,Hltb100,Photo")] GamesModel gamesModel) { if (id != gamesModel.ID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(gamesModel); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!GamesModelExists(gamesModel.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(gamesModel)); }
public async Task <IActionResult> Create([Bind("ID,Name,Genre,GameStatus,PremiereDate,DeveloperID,Hltb,Hltb100,Photo")] GamesModel gamesModel, IFormFile photo) { if (ModelState.IsValid) { _context.Add(gamesModel); await _context.SaveChangesAsync(); if (photo == null) { return(RedirectToAction(nameof(Index))); } else { var path = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot/images", photo.FileName); var stream = new FileStream(path, FileMode.Create); await photo.CopyToAsync(stream); gamesModel.Photo = photo.FileName; } return(RedirectToAction(nameof(Index))); } return(View(gamesModel)); }
public DetailPage(GamesModel model) { InitializeComponent(); BindingContext = new MainDetailPageViewModel(model) { Navigation = this.Navigation }; }
public ActionResult DeleteConfirmed(int id) { GamesModel gamesModel = db.Games.Find(id); db.Games.Remove(gamesModel); db.SaveChanges(); return(RedirectToAction("Index")); }
// GET: BacklogList public ActionResult BacklogGames() { GamesModel games = new GamesModel(); games.Platform = "Nintendo 64"; games.GameName = "Goldeneye 007"; return(View()); }
public static string[] GetSettings() { GamesModel gm = new GamesModel(); string[] settings = gm.GetSettingScenePuzzle(); //gm.GetSettingScenePuzzle(); return(settings); }
// GET: Games public ActionResult Games() { GamesModel games = new GamesModel(1, Convert.ToDateTime("08/18/2020"), 1); games.GameCards = GenerateGames(games.QuantityOfCards); return(View()); }
public ActionResult Edit([Bind(Include = "GameId,GameName,Platform,DateCompleted")] GamesModel gamesModel) { if (ModelState.IsValid) { db.Entry(gamesModel).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(gamesModel)); }
private async Task InsertEmptyGamesAsync(string email) { var gamesInstance = new GamesModel { Id = email, Games = new List <GameModel> () }; await _gamesDocumentDbManager.AddGamesAsync(gamesInstance); }
public ActionResult Create([Bind(Include = "GameId,GameName,Platform,DateCompleted")] GamesModel gamesModel) { if (ModelState.IsValid) { db.Games.Add(gamesModel); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(gamesModel)); }
public ActionResult Index() { var games = gameService.GetAllGames(); var models = mapper.Map <IEnumerable <Game>, IEnumerable <GameViewModel> >(games); var model = GamesModel.CreateGameModel(models, UserHelper.IsAdmin(User, context)); SetGenresDevelopers(); return(View(model)); }
private async Task <ProcessGameActionResponse> InsertGame(GamesModel games, GameModel game) { games.Games.Add(game); await _gamesDocumentDbManager.UpdateGamesAsync(games); return(new ProcessGameActionResponse() { Id = game.Id, Success = true, Errors = new string[0] }); }
private static void AssertEntity(GamesModel entity) { if (entity == null) { throw new ArgumentNullException(nameof(entity), "Entity can not be null"); } if (string.IsNullOrEmpty(entity.Id)) { throw new ArgumentException(nameof(entity), $"Properties id can not be null or empty"); } }
public ActionResult Index() { var players = PlayerService.GetPlayers(); var model = new GamesModel(); model.AvailablePlayers = players.Select(x => new PlayerModel { Name = x.Name }).ToList(); return(View(model)); }
public async Task <IActionResult> Index() { var games = await GetGamesFromApi(); var model = new GamesModel(); if (games.IsNotNull()) { model.Games.AddRange(games); } return(View(model)); }
private void save_progress() { SaveService.DeleteSave(); // clear table before save new data for (int i = 0; i < PuzzlesService.puzzleArray.Length; i++) { SaveService.SetSave(PuzzlesService.puzzleArray[i]); } GamesModel gm = new GamesModel(); gm.SaveBreakGame(StartPuzzle.gamesID); }
public async Task AddGamesAsync(GamesModel games) { AssertEntity(games); try { Trace.TraceInformation($"Creating document: {JsonConvert.SerializeObject(games, Formatting.Indented)}"); await _documentClient.CreateDocumentAsync(CreateCollectionUri(), games, null, true); } catch (Exception ex) { Trace.TraceError($"ERROR CREATING DOCUMENT: {ex}"); } }
public async Task <GamesModel> GetGames(string email) { GamesModel games = _gamesDocumentDbManager.GetGames(email); if (games == null) { await InsertEmptyGamesAsync(email); games = _gamesDocumentDbManager.GetGames(email); } return(games); }
// GET: Games/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } GamesModel gamesModel = db.Games.Find(id); if (gamesModel == null) { return(HttpNotFound()); } return(View(gamesModel)); }
public ActionResult Edit(GamesModel gameModel) { var repository = ServiceFactory.GetInstance <IGameRepository>(); if (ModelState.IsValid) { var game = repository.First(g => g.ID == gameModel.ID); game.Name = gameModel.Name; game.HtmlContent = gameModel.HtmlContent.ToHtmlEncode(); ServiceFactory.GetInstance <IGameRepository>().SaveChanges(); return(RedirectToAction("Edit", "Game", new { id = game.ID })); } return(View()); }
protected override async Task OnInitializedAsync() { _gameDetailStateManagement = new GameDetailState(Service); _gameDetailStateManagement.HandleGameLoaded += GameLoaded; _gameDetailStateManagement.HandleRatingsLoaded += RatingsLoaded; _gameDetailStateManagement.OnGameSavedSuccessfully += OnSaved; if (GameId > 0) { await _gameDetailStateManagement.LoadGame(GameId); } else { _game = new GamesModel(); } await _gameDetailStateManagement.LoadRatings(); }
public bool InsertGame(GamesModel games) { using (IDbConnection cnn = new ApplicationDbContext().Database.Connection) { string sql = $"INSERT INTO dbo.Games(PlayerName,Age,HourGame,Score) VALUES('{games.PlayerName}','{games.Age}','{games.HourGame}','{games.Score}')"; int rows = cnn.Execute(sql); if (rows != 1) { return(false); } else { return(true); } } }
private List <GamesModel> TranslateDataTableToGamesModel(DataTable dataTable) { List <GamesModel> gamesModels = new List <GamesModel>(); foreach (DataRow row in dataTable.Rows) { GamesModel gamesModel = new GamesModel(); gamesModel.GameID = row["GameID"] != DBNull.Value ? Convert.ToInt64(row["GameID"].ToString()) : 0; gamesModel.MainTopicID = row["MainTopicID"] != DBNull.Value ? Convert.ToInt64(row["MainTopicID"].ToString()) : 0; gamesModel.MainTopicNumber = row["MainTopicNumber"] != DBNull.Value ? Convert.ToString(row["MainTopicNumber"]) : string.Empty; gamesModel.GameDescription = row["GameDescription"] != DBNull.Value ? Convert.ToString(row["GameDescription"].ToString()) : string.Empty; gamesModels.Add(gamesModel); } return(gamesModels); }
public async Task <ProcessGameActionResponse> SaveGames(string email, int gameId, GameModel game) { ProcessGameActionResponse response; GamesModel games = _gamesDocumentDbManager.GetGames(email); GameModel gameDb = games.Games.Find(x => x.Id == gameId + ""); if (gameDb != null) { games.Games.Remove(gameDb); response = await InsertGame(games, game); } else { response = await InsertGame(games, game); } return(response); }
public virtual HttpResponseMessage GetGames(int skip, int take) { if (skip < 0) { return(Request.CreateResponse(HttpStatusCode.BadRequest, "Skip cannot be negative.")); } if (take < 0) { return(Request.CreateResponse(HttpStatusCode.BadRequest, "Take cannot be negative.")); } var games = DataBridge.GetGames(skip, take); var result = new GamesModel { Games = games, MoreGames = games.Count == take }; return(Request.CreateResponse(HttpStatusCode.OK, result)); }
private async Task <GamesModel> GetRecord(string id) { GamesModel record = null; try { ResourceResponse <Document> response = await _documentClient.ReadDocumentAsync(CreateDocumentUri(id)); if (response.StatusCode == HttpStatusCode.OK) { record = (GamesModel)(dynamic)response.Resource; } } catch (Exception ex) { Trace.TraceError($"ERROR READING DOCUMENT {id}: {ex}"); } return(record); }
public ProcessGameActionResponse Remove(string email, int gameId) { ProcessGameActionResponse response = null; GamesModel games = _gamesDocumentDbManager.GetGames(email); GameModel gameDb = games.Games.Find(x => x.Id == gameId + ""); if (gameDb != null) { games.Games.Remove(gameDb); response = new ProcessGameActionResponse() { Id = "", Success = true, Errors = new string[0] }; } return(response); }
public ActionResult Filter(string type, string name) { var games = default(IEnumerable <Game>); var typeNull = string.IsNullOrWhiteSpace(type); var nameNull = string.IsNullOrWhiteSpace(name); if (!typeNull && !nameNull) { AddFilter(type, name); games = gameService.FilterGames(Session["GameFilters"] as List <GameFilter>); } else { games = gameService.GetAllGames(); } var models = mapper.Map <IEnumerable <Game>, IEnumerable <GameViewModel> >(games); var model = GamesModel.CreateGameModel(models, UserHelper.IsAdmin(User, context)); return(PartialView("Partial/GamesPartial", model)); }