public IHttpActionResult GetLicense(long licenseId)
 {
     try
     {
         return(Ok(_licenseService.GetLicense(licenseId)));
     }
     catch (Exception ex)
     {
         return(InternalServerError(ex));
     }
 }
Exemplo n.º 2
0
        private List <ResultListViewModel> GetResultsFromCmd(OleDbCommand cmd)
        {
            List <ResultListViewModel> results = new List <ResultListViewModel>();

            using (OleDbDataReader dbReader = cmd.ExecuteReader())
            {
                int _playerName    = dbReader.GetOrdinal("list_name");
                int _playerNumber  = dbReader.GetOrdinal("player_nr");
                int _setsPlayed    = dbReader.GetOrdinal("sets_played");
                int _setsWon       = dbReader.GetOrdinal("sets_won");
                int _percentage    = dbReader.GetOrdinal("percentage");
                int _rating        = dbReader.GetOrdinal("rating");
                int _baseRating    = dbReader.GetOrdinal("base_rating");
                int _teamId        = dbReader.GetOrdinal("team_id");
                int _clubId        = dbReader.GetOrdinal("club_id");
                int _clubName      = dbReader.GetOrdinal("club_name");
                int _teamNumber    = dbReader.GetOrdinal("team_number");
                int _seasonId      = dbReader.GetOrdinal("season_id");
                int _seasonYear    = dbReader.GetOrdinal("season_year");
                int _seasonPeriod  = dbReader.GetOrdinal("season_period");
                int _pouleId       = dbReader.GetOrdinal("poule_id");
                int _className     = dbReader.GetOrdinal("class_name");
                int _classLevel    = dbReader.GetOrdinal("class_level");
                int _pouleName     = dbReader.GetOrdinal("poule_name");
                int _pouleCategory = dbReader.GetOrdinal("poule_category");
                int _regionName    = dbReader.GetOrdinal("region_name");
                int _regionId      = dbReader.GetOrdinal("region_id");

                while (dbReader.Read())
                {
                    var result = new ResultListViewModel();

                    result.playerName = dbReader.GetString(_playerName);
                    result.playerNr   = dbReader.GetString(_playerNumber);

                    result.setsPlayed = dbReader.GetInt32(_setsPlayed);
                    result.setsWon    = dbReader.GetInt32(_setsWon);

                    result.percentage = dbReader.GetInt32(_percentage);

                    result.sortPercentage = 0;
                    if (_setsPlayed > 0)
                    {
                        result.sortPercentage = (double)result.setsWon / (double)result.setsPlayed;
                    }

                    result.rating     = dbReader.GetInt32(_rating);
                    result.baseRating = dbReader.GetInt32(_baseRating);

                    result.clubId     = dbReader.GetInt32(_clubId);
                    result.clubName   = dbReader.GetString(_clubName);
                    result.teamId     = dbReader.GetInt32(_teamId);
                    result.teamNumber = dbReader.GetInt32(_teamNumber);

                    result.seasonId     = dbReader.GetInt32(_seasonId);
                    result.seasonYear   = dbReader.GetInt32(_seasonYear);
                    result.seasonPeriod = dbReader.GetInt32(_seasonPeriod);

                    result.pouleId       = dbReader.GetInt32(_pouleId);
                    result.pouleName     = dbReader.GetString(_pouleName);
                    result.pouleCategory = dbReader.GetInt32(_pouleCategory);
                    result.className     = dbReader.GetString(_className);
                    result.classLevel    = dbReader.GetInt32(_classLevel);

                    result.regionId   = dbReader.GetInt32(_regionId);
                    result.regionName = dbReader.GetString(_regionName);

                    result.license = LicenseService.GetLicense(result.rating, result.regionName, result.pouleCategory);

                    results.Add(result);
                }
            }

            return(results);
        }