public async Task <IActionResult> LatestByPresenter(string handle, CancellationToken ct) { var show = await _context.Shows .Where(s => s.Presenter == handle) .OrderByDescending(s => s.Time) .Take(1) .FirstOrDefaultAsync(ct) .ConfigureAwait(false); return(show == null?NotFound() : Ok(ShowDto.FromShow(show))); }
public async Task <IActionResult> Get(string presenter, string slug, CancellationToken ct) { var show = await _context.Shows.SingleOrDefaultAsync(s => s.Presenter == presenter && s.Slug == slug, ct).ConfigureAwait(false); return(show == null?NotFound() : Ok(ShowDto.FromShow(show))); }
public async Task <IActionResult> Start([FromBody] Show show, CancellationToken ct) { try { _context.Shows.Add(show); await _context.SaveChangesAsync(ct).ConfigureAwait(false); return(CreatedAtAction("Get", "Shows", new { presenter = show.Presenter, slug = show.Slug }, ShowDto.FromShow(show))); } catch (System.Exception ex) { _logger.LogError(EventIds.DatabaseError, ex, ex.Message); throw; } }