public async Task RebuildMatchInfos() { var exceptions = new List <Exception>(); foreach (var match in await _context.Matches.ToArrayAsync()) { var currentMatch = new DatabaseMatchService(_context, match.Id, match.UserId); try { await currentMatch.RebuildMatchInfoAsync(); } catch (InvalidOperationException ex) { exceptions.Add(new Exception("Error during rebuilding MatchInfo of match#" + match.Id, ex) { Data = { ["MatchId"] = match.Id } }); } } if (exceptions.Count > 0) { throw new AggregateException(exceptions); } }
public async Task <IEnumerable <MatchModel> > GetMatchesWithUser(string userId) { var result = new List <MatchModel>(); foreach (var match in await _context.Matches.Where(match => match.UserId == userId).Select(match => match.Id).ToArrayAsync()) { var currentMatch = new DatabaseMatchService(_context, match, userId); var state = await currentMatch.GetStateAsync(); result.Add(state); } return(result); }