public async Task <ActionResult <List <DsReplayResponse> > > ReplayRequest(DsReplayRequest request, CancellationToken cancellationToken) { if (!cancellationToken.IsCancellationRequested) { return(await ReplayService.GetReplays(context, request, cancellationToken)); } else { return(Ok()); } }
public static IQueryable <Dsreplay> Filter(sc2dsstatsContext context, DsReplayRequest request) { if (request.Filter == null || request.Filter.isDefault) { return(DefaultFilter(context)); } else { return(GetFilteredReplays(context, request.Filter, DateTime.MinValue, DateTime.Today)); } }
public async Task <int> GetReplaysCount(DsReplayRequest request) { return(await sc2dsstats.db.Services.ReplayService.GetCount(context, request)); }
public async Task <List <DsReplayResponse> > GetReplays(DsReplayRequest request, CancellationToken cancellationToken) { return(await sc2dsstats.db.Services.ReplayService.GetReplays(context, request, cancellationToken)); }
public async Task <ActionResult <int> > CountRequest(DsReplayRequest request) { return(await ReplayService.GetCount(context, request)); }
public static async Task <List <DsReplayResponse> > GetReplays(sc2dsstatsContext context, DsReplayRequest request, CancellationToken cancellationToken) { var replays = GetQueriableReplays(context, request); if (request.sortOrders != null && request.sortOrders.Any()) { foreach (var sortOrder in request.sortOrders) { if (sortOrder.Order) { replays = replays.AppendOrderBy(sortOrder.Sort); } else { replays = replays.AppendOrderByDescending(sortOrder.Sort); } } } else { replays = replays.OrderByDescending(o => o.Gametime); } replays = replays.Skip(request.Skip).Take(request.Take); List <DsReplayResponse> replayResponses = new List <DsReplayResponse>(); if (!cancellationToken.IsCancellationRequested) { try { replayResponses = await replays.Select(s => new DsReplayResponse() { Id = s.Id, Hash = s.Hash, Races = s.Dsplayers.OrderBy(o => o.Realpos).Select(r => ((Commander)r.Race).ToString()).ToList(), Players = s.Dsplayers.OrderBy(o => o.Realpos).Select(r => r.Name).ToList(), Gametime = s.Gametime, Duration = s.Duration, PlayerCount = s.Playercount, GameMode = ((Gamemode)s.Gamemode).ToString(), MaxLeaver = s.Maxleaver, MaxKillsum = s.Maxkillsum, Winner = s.Winner, DefaultFilter = s.DefaultFilter }).ToListAsync(cancellationToken); } catch (TaskCanceledException) { return(replayResponses); } }