コード例 #1
0
        public IActionResult Get(int?sportId, int?countryId)
        {
            try
            {
                if (!sportId.HasValue && !countryId.HasValue)
                {
                    return(StatusCode(400, StatusCodes.ReturnStatusObject("No parameters provided.")));
                }
                var result = _tournamentRepository.GetAllTournamentsForSportBasedOnCountry(sportId, countryId);

                if (result.Any())
                {
                    _logger.LogInformation("Get tournaments for sport id : {0} and countryId : {1} successful.", sportId, countryId);
                    return(Ok(result));
                }
                else
                {
                    _logger.LogInformation("No items for tournaments for sport id : {0} and countryId : {1}.", sportId, countryId);
                    return(StatusCode(400, StatusCodes.ReturnStatusObject("No items found")));
                }
            }
            catch (Exception e)
            {
                _logger.LogError("Failed to get items for tournaments for sport id : {0} and countryId : {1}. Error - {2}", sportId, countryId, e.Message);
                return(StatusCode(400, StatusCodes.ReturnStatusObject("Failed to recivece items.")));
            }
        }