Beispiel #1
0
        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)));
        }
Beispiel #2
0
        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)));
        }
Beispiel #3
0
        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;
            }
        }