public IActionResult GetTournament(int?tournamentId)
        {
            try
            {
                if (!tournamentId.HasValue)
                {
                    return(StatusCode(400, StatusCodes.ReturnStatusObject("No parameters provided.")));
                }
                var result = _tournamentRepository.GetTournament(tournamentId);

                if (result != null)
                {
                    _logger.LogInformation("Get tournaments for tournamentId {0} successful.", tournamentId);
                    return(Ok(result));
                }
                else
                {
                    _logger.LogInformation("No items for tournaments  for tournamentId {0}.", tournamentId);
                    return(StatusCode(400, StatusCodes.ReturnStatusObject("No items found")));
                }
            }
            catch (Exception e)
            {
                _logger.LogError("Failed to get items for tournaments  for tournamentId {0}. Error - {1}", tournamentId, e.Message);
                return(StatusCode(400, StatusCodes.ReturnStatusObject("Failed to recivece items.")));
            }
        }
示例#2
0
        private void WriteTournamentToDB(ITournament table)
        {
            Tournament t = dbMgr.InsertTournament(table.GetTournament());

            foreach (Player p in table.GetPlayers())
            {
                TournamentResult res = table.GetResult(p);
                res.Event = t;
                dbMgr.InsertResult(res);

                int newRate = EloTable.GetNewRate(p.GetRate(table.GetGameType()), table.GetAverageRate(p), table.GetMaxPoints(p), table.GetResult(p).Points);
                Player tp = p.Clone();
                tp.SetRate(table.GetGameType(), newRate);
                tp.SetUpdateDate(t.Type, t.EndOn);
                dbMgr.UpdatePlayer(tp);
            }

            foreach (Game g in table.GetGames())
            {
                g.Tournament = t;
                dbMgr.InsertGame(g);
            }

            ReloadPlayersAndView();
        }