Пример #1
0
        public IActionResult Get(long?marketid)
        {
            try
            {
                if (marketid.HasValue)
                {
                    _logger.LogInformation("API Request hit: GET all Markets by Id: " + marketid.Value);
                    var result = _marketRepository.GetMarket(marketid.Value);
                    if (result.ToList().Any())
                    {
                        return(Ok(result));
                    }
                    else
                    {
                        _logger.LogInformation("API Request (GET all Markets by SportId: " + marketid.Value + " ) no entries found");
                        return(NotFound("Sport was not found with Id: " + marketid.Value));
                    }
                }
                else
                {
                    _logger.LogInformation("API Request hit: GET all Markets by no criteria");
                    var result = _marketRepository.GetMarkets();
                    return(Ok(result));
                }
            }

            catch (Exception e)
            {
                _logger.LogError("API Request (GET all Markets by Id) FAILED: ", e);
                return(BadRequest("Failed"));
            }
        }