Beispiel #1
0
        public async Task <string> Import()
        {
            Dictionary <int, ResultModel> newResults = new Dictionary <int, ResultModel>();

            try
            {
                List <AdminController.Record> loadData = await this.LoadData();



                foreach (AdminController.Record r in loadData)
                {
                    if (!MatchesController.MatchExists(r.One, r.Two))
                    {
                        continue;
                    }

                    MatchModel match = MatchesController.GetMatch(r.One, r.Two);

                    int resultId = match.ResultId;
                    int matchId  = match.Id;

                    ResultModel result = ResultController.GetResult(resultId);
                    if (this.ParseForResult(result, r.Result))
                    {
                        newResults.Add(matchId, result);
                    }
                }
                if (newResults.Count > 0)
                {
                    log.Info($"New results were loaded. Count: {newResults.Count}");
                    new PointsCounter().CountPoints(newResults);
                    ResultController.SaveChanges();
                }
            }
            catch (Exception e)
            {
                log.Error("error in loading data", e);
                return(e.Message);
            }
            return(newResults.Count.ToString());
        }
Beispiel #2
0
        public string Import()
        {
            Dictionary <int, ResultModel> newResults = new Dictionary <int, ResultModel>();

            try
            {
                List <Record> loadData = this.LoadData();



                foreach (Record r in loadData)
                {
                    if (!MatchesController.MatchExists(r.One, r.Two))
                    {
                        continue;
                    }

                    MatchModel match = MatchesController.GetMatch(r.One, r.Two);

                    int resultId = match.ResultId;
                    int matchId  = match.Id;

                    ResultModel result = ResultController.GetResult(resultId);
                    if (this.ParseForResult(result, r.Result))
                    {
                        newResults.Add(matchId, result);
                    }
                }
                if (newResults.Count > 0)
                {
                    pointsCounter.CountPoints(newResults);
                    ResultController.SaveChanges();
                }
            }
            catch (Exception e)
            {
                log.Error("Error in importing results");
                return(e.Message);
            }
            return(newResults.Count.ToString());
        }