public async Task <ActionResult <NoteDto> > GetForSlide(string place, string presenter, string slug, int number, CancellationToken ct) { if (!User.Identity.IsAuthenticated) { return(new NoteDto()); } var slideIdentifier = $"{place}/{presenter}/{slug}/{number}"; var user = User.FindFirstValue(DeckHubClaimTypes.Handle); try { var existingNote = await _context.Notes .SingleOrDefaultAsync(n => n.UserHandle == user && n.SlideIdentifier == slideIdentifier, ct) .ConfigureAwait(false); if (existingNote == null) { return(new NoteDto { UserIsAuthenticated = true }); } var dto = NoteDto.FromNote(existingNote); dto.UserIsAuthenticated = true; return(dto); } catch (Exception ex) { _logger.LogError(EventIds.DatabaseError, ex, ex.Message); throw; } }
public static TagDto FromTag(Tag tag) => new TagDto { TagId = tag.TagId, Name = tag.Name, Slug = tag.Slug, Notes = tag.NoteTags.Select(x => NoteDto.FromNote(x.Note, false)).ToList() };
public async Task <IActionResult> GetForSlide(string user, string presenter, string slug, int number, CancellationToken ct) { var slideIdentifier = $"{presenter}/{slug}/{number}"; try { var existingNote = await _context.Notes .SingleOrDefaultAsync(n => n.UserHandle == user && n.SlideIdentifier == slideIdentifier, ct) .ConfigureAwait(false); return(existingNote == null?NotFound() : Ok(NoteDto.FromNote(existingNote))); } catch (Exception ex) { _logger.LogError(EventIds.DatabaseError, ex, ex.Message); throw; } }