public async Task FillBaseOnce() { var events = await GetEventsFromTarget(); events = events.Results.ToPoll(); var tasks = events.Results.Select(async(x) => { var place = await AddPlaceToDatabase(placesRepository, x.Place); x.Place.Id = place.Id; await eventsRepository.AddAsync(x); }); await Task.WhenAll(tasks); }
private async Task <List <int> > GetInplayGameIds() { var result = new List <int>(); var response = await _betsApiClient.GetInplayEventsAsync((int)SportId.TableTennis, _configuration.BetsApiAccessToken); if (response?.Results == null) { return(result); } foreach (var e in response.Results) { var wasRetrieved = await _eventsRepository.ExistsAsync(e.Id); if (wasRetrieved) { continue; } result.Add(e.Id); await _eventsRepository.AddAsync(e.Id); } return(result); }
public async Task <ActionResult <EventViewModel> > AddEventAsync([FromBody] EventViewModel eventViewModel) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var @event = await eventsRepository.AddAsync(eventViewModel); return(CreatedAtAction(actionName: nameof(GetEventAsync), routeValues: new { id = @event.Id }, value: @event.ToViewModel())); }