public IActionResult Get(long?tournamentid)
        {
            try
            {
                if (tournamentid.HasValue)
                {
                    _logger.LogInformation("API Request hit: GET all MarketOdds by TournamentId: " + tournamentid.Value);
                    var result = _marketRepository.Get(tournamentid);
                    if (result.ToList().Any())
                    {
                        return(Ok(result));
                    }
                    else
                    {
                        _logger.LogInformation("API Request (GET all MarketOdds by TournamentId: " + tournamentid.Value + " ) no entries found");
                        return(NotFound("MarketOdds were not found with TournamentId: " + tournamentid.Value));
                    }
                }
                else
                {
                    _logger.LogInformation("API Request hit: GET all MarketOdds by no criteria");
                    var result = _marketRepository.GetAll();
                    return(Ok(result));
                }
            }

            catch (Exception e)
            {
                _logger.LogError("API Request (GET all MarketOdds by TournamentId) FAILED: ", e);
                return(BadRequest());
            }
        }
        public async Task <IActionResult> GetAllMarkets()
        {
            var markets = await _marketRepository.GetAll();

            var orderBooks = new List <OrderBook>();

            foreach (var market in markets)
            {
                orderBooks.Add(market.GetOrderBook());
            }

            return(Ok(orderBooks));
        }
Esempio n. 3
0
        public HttpResponseMessage Get(HttpRequestMessage request)
        {
            var _ = request.CreateResponse(HttpStatusCode.OK, _marketRepository.GetAll());

            return(_);
        }