public void OnPointerClick(PointerEventData data) { Component[] renderes; GamePick gp = (GamePick)GameObject.FindWithTag("GameController").GetComponent <GamePick>(); if (gameObject.tag == "Focus") { gameObject.tag = "Untagged"; gameObject.transform.localScale = new Vector3(0.5f, 0.5f, 0.5f); gameObject.transform.position = gp.originalPosition; renderes = GetComponentsInChildren <Renderer>(); foreach (Renderer renderer in renderes) { renderer.sortingOrder = renderer.sortingOrder - 200; } if (!gp.chosen) { gp.pick.SetActive(false); } } else { GameObject focus = GameObject.FindWithTag("Focus"); if (focus != null) { focus.tag = "Untagged"; focus.transform.localScale = new Vector3(0.5f, 0.5f, 0.5f); focus.transform.position = gp.originalPosition; renderes = focus.GetComponentsInChildren <Renderer>(); foreach (Renderer renderer in renderes) { renderer.sortingOrder = renderer.sortingOrder - 200; } } gp.originalPosition = gameObject.transform.position; gameObject.transform.localScale = new Vector3(1.2f, 1.2f, 1.2f); gameObject.transform.position = new Vector3(0, 0, 0); renderes = GetComponentsInChildren <Renderer>(); foreach (Renderer renderer in renderes) { renderer.sortingOrder = renderer.sortingOrder + 200; } gameObject.tag = "Focus"; if (!gp.chosen) { gp.pick.SetActive(true); } } }
public async Task <GamePick> CreateAsync(Game game, User user) { GamePick gamePick = new GamePick() { Game = game, GameId = game.Id, User = user, UserId = user.Id }; await _dbContext.AddAsync(gamePick); await _dbContext.SaveChangesAsync(); return(gamePick); }
public Task <GamePick> CreateAsync(Game game, User user) { GamePick gamePick = new GamePick() { Id = _currentId++, Game = game, GameId = game.Id, User = user, UserId = user.Id }; _gamePicks.Add(gamePick.Id, gamePick); return(Task.FromResult(gamePick)); }
private async Task SortAndFillPickWagersAsync(List <PickEmLeagueDatabase.Entities.Game> games, long userId, int week) { GamePick[] finalPicks = new GamePick[games.Count]; List <GamePick> picksToFinalize = new List <GamePick>(); var currentPicks = _mapper.Map <IEnumerable <GamePick> >( _gamePickRepository.GetByUserAndWeek(userId, week)).ToList(); // remove zero wagers picksToFinalize = currentPicks.Where(gp => gp.Wager == 0).ToList(); picksToFinalize.ForEach(pick => currentPicks.Remove(pick)); // fill in wagers from remaining current picks foreach (var pick in currentPicks) { if (finalPicks[pick.Wager - 1] != null) { picksToFinalize.Add(pick); } else { finalPicks[pick.Wager - 1] = pick; } } // Fill in from picks to finalize and set their wager value foreach (var pick in picksToFinalize) { for (int i = 0; i < finalPicks.Length; i++) { if (finalPicks[i] == null) { pick.Wager = i + 1; finalPicks[i] = pick; break; } } } foreach (var pick in finalPicks) { await _gamePickRepository.UpdateAsync(pick); } }
private void Fill_GamePick(IWebElement moreBetsPage, Game game) { HtmlNodeCollection htmlNodeCollection = null; int countDiv = 0; while (htmlNodeCollection == null) { string pgData = this.driver1.PageSource.Replace(System.Environment.NewLine, "").Replace("\t", ""); htmlNodeCollection = generalMethods.FindSpecificElements(generalMethods.ParseHtmlPageSource(pgData), string.Format("(//div[@id='MarketListContentComponent32-event-{0}-group-1'])", game.DynamicId)); } if (htmlNodeCollection != null && htmlNodeCollection.Count > 0) { if (htmlNodeCollection[0].ChildNodes.Count > 0 && htmlNodeCollection[0].ChildNodes.Count == 1) { countDiv = htmlNodeCollection[0].ChildNodes[0].ChildNodes.Count; //behavior.id="ToggleMarket" // \"toggler\" foreach (HtmlNode gamePick in htmlNodeCollection[0].ChildNodes[0].ChildNodes) { if (gamePick.ChildNodes.Count > 0) { if (gamePick.ChildNodes[0].ChildNodes.Count > 0) { using (OddsContext context = new OddsContext()) { GamePick gamePickRecord = new GamePick(); // Foreach \"market\" class foreach (HtmlNode market in gamePick.ChildNodes[0].ChildNodes) { //HtmlNode lastNode = findLastChildNode(market); if (market.Name.Equals("h2")) { string GamePickDescr = market.FirstChild.InnerText; gamePickRecord = context.GamePick.FirstOrDefault(x => x.GameId == game.Id && x.Descr.Equals(GamePickDescr)); if (gamePickRecord == default(GamePick)) { gamePickRecord = new GamePick(); context.GamePick.Add(gamePickRecord); gamePickRecord.Id = _dataBase.X_getGID("GamePick"); gamePickRecord.GameId = game.Id; } gamePickRecord.Descr = GamePickDescr; gamePickRecord.OddSumNum = 0; context.SaveChanges(); } if (market.Name.Equals("table")) { foreach (HtmlNode tableNode in market.FirstChild.ChildNodes) { foreach (HtmlNode trNode in tableNode.ChildNodes) { if (trNode.ChildNodes.Count > 0) { foreach (HtmlNode tdNode in trNode.FirstChild.ChildNodes) { gamePickRecord.OddSumNum++; // Left Td String Value string leftTd = tdNode.FirstChild.FirstChild.InnerText; string rightTd = tdNode.FirstChild.LastChild.InnerText; GamePickValue gamePickValue = context.GamePickValue.FirstOrDefault(x => x.Descr.Equals(leftTd) && x.GamePickId == gamePickRecord.Id); if (gamePickValue == default(GamePickValue)) { gamePickValue = new GamePickValue(); context.GamePickValue.Add(gamePickValue); gamePickValue.Id = _dataBase.X_getGID("GamePickValue"); gamePickValue.PickValue = Convert.ToDouble(rightTd.Replace(',', '.')); } else { //gamePickValue.ChangedValue = Convert.ToDouble(rightTd.Replace(',', '.')); } gamePickValue.Descr = gamePickValue.AlternativeDescr = leftTd; gamePickValue.OddsUpdated = DateTime.Now; gamePickValue.GamePickId = gamePickRecord.Id; gamePickValue.CompanyId = 1; context.SaveChanges(); } } } } } } } } } string t = gamePick.Name; } } } using (OddsContext context = new OddsContext()) { List <GamePick> gamePickRecord = context.GamePick.Where(x => x.GameId == game.Id).ToList(); if (gamePickRecord.Count == countDiv) { Console.WriteLine($"Game {game.Descr} has all records"); } } }