public async Task <ActionResult <GameModel> > GetGameAsync(long matchId) { _logger.LogInformation($"Trying to get 100 last games League Of Legend by name: {matchId}"); try { if (_ListChampion == null) { var GetValueAllChamp = await _DragonClient.GetAllChampAsync(); _ListChampion = JsonConvert.DeserializeObject <ListAllChampModel>(GetValueAllChamp); } if (_ListItems == null) { var GetValueAllItems = await _DragonClient.GetAllItemsAsync(); _ListItems = JsonConvert.DeserializeObject <ListItemsModel>(GetValueAllItems); } if (_ListSummoners == null) { var GetValueAllSummoners = await _DragonClient.GetAllSummonersAsync(); _ListSummoners = JsonConvert.DeserializeObject <ListSummonersModel>(GetValueAllSummoners); } var token = _settings.GetSection("lol").GetSection("token").Value; var GamesUser = await _GameClient.GetGameAsync(token, matchId); var Result = JsonConvert.DeserializeObject <GameModel>(GamesUser); AnalyseTeam(Result); AnalyseParticipants(Result); return(Result); } catch (ApiException exception) { _logger.LogInformation($"Echec to get 100 last games League Of Legend by name: {exception.StatusCode}"); return(StatusCode((int)exception.StatusCode)); } catch (Exception exc) { _logger.LogInformation($"Critical error: {exc.Message}"); return(StatusCode(500)); } }
//public List<DistanceOfItems> DistancePriceAndTaxCode(string HtmlResult) //{ // List<ResponseGoogleVision.TextAnnotation> listTaxCode = GetItemWithTaxCode(HtmlResult); // List<ResponseGoogleVision.TextAnnotation> listPrice = GetItemWithPrice(HtmlResult); // List<DistanceOfItems> listDistance = new List<DistanceOfItems>(); // foreach (var taxCode in listTaxCode) // { // int xTaxCode = taxCode.boundingPoly.vertices[0].x; // int yTaxCode = taxCode.boundingPoly.vertices[0].y; // foreach (var price in listPrice) // { // int xPrice = price.boundingPoly.vertices[0].x; // int yPrice = price.boundingPoly.vertices[0].y; // double distance = Math.Pow(xPrice - xTaxCode, 2) + Math.Pow(yPrice - yTaxCode, 2); // DistanceOfItems item = new DistanceOfItems(); // item.TaxCode = taxCode.description; // item.Price = price.description; // item.Distance = distance; // listDistance.Add(item); // } // } // return listDistance.Distinct().GroupBy(p => p.TaxCode, // (key, g) => new DistanceOfItems { TaxCode = key, Price = g.FirstOrDefault(x => x.Distance == g.Min(x => x.Distance))?.Price, Distance = g.Min(x => x.Distance) }).ToList(); //} public List <ListItemsModel> GetAll(string HtmlResult) { List <ResponseGoogleVision.TextAnnotation> listTaxCode = GetItemWithTaxCode(HtmlResult); List <ResponseGoogleVision.TextAnnotation> listTicketNumber = GetItemWithTicketNumber(HtmlResult); List <ResponseGoogleVision.TextAnnotation> listPrice = GetItemWithPrice(HtmlResult); List <ListItemsModel> listItems = new List <ListItemsModel>(); ListItemsModel item = new ListItemsModel(); if (listTaxCode.Count == 0) { item.TaxCode = ""; } else { item.TaxCode = listTaxCode[0].description; } if (listTicketNumber.Count == 0) { item.TicketNumber = ""; } else { item.TicketNumber = listTicketNumber[0].description; } if (listPrice.Count == 0) { item.Price = ""; } else { item.Price = listPrice[listPrice.Count - 1].description; } listItems.Add(item); return(listItems); }