예제 #1
0
        public IActionResult GetBets(long?id)
        {
            try
            {
                if (id.HasValue)
                {
                    _logger.LogInformation("API Request hit: GET all Bet by BetSlipId: " + id.Value);
                    var result = _betRepository.GetBetInfo(id.Value);
                    if (result.ToList().Any())
                    {
                        return(Ok(result));
                    }
                    else
                    {
                        _logger.LogInformation("API Request (GET all Bet by BetSlipId: " + id.Value + " ) no entries found");
                        return(NotFound("Bets were not found with BetSlipId: " + id.Value));
                    }
                }
                else
                {
                    _logger.LogInformation("API Request hit: GET all Bets by no criteria");
                    var result = _betRepository.GetAllBets();
                    return(Ok(result));
                }
            }

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