public async Task <Response> Handle(Request request, CancellationToken cancellationToken)
 {
     return(new Response()
     {
         Note = NoteApiModel.FromNote(await _context.Notes
                                      .Include(x => x.NoteTags)
                                      .Include("NoteTags.Tag")
                                      .Where(x => x.Slug == request.Slug)
                                      .SingleAsync())
     });
 }
        public static NoteApiModel FromNote(Note note, bool includeTags = true)
        {
            var model = new NoteApiModel
            {
                NoteId = note.NoteId,
                Title  = note.Title,
                Slug   = note.Slug,
                Body   = note.Body
            };

            if (includeTags)
            {
                model.Tags = note.NoteTags.Select(x => TagApiModel.FromTag(x.Tag)).ToList();
            }

            return(model);
        }
Beispiel #3
0
 public async Task <Response> Handle(Request request, CancellationToken cancellationToken)
 => new Response()
 {
     Note = NoteApiModel.FromNote(await _context.Notes.FindAsync(request.NoteId))
 };
 public async Task <Response> Handle(Request request, CancellationToken cancellationToken)
 => new Response()
 {
     Notes = await _context.Notes.Select(x => NoteApiModel.FromNote(x, true)).ToListAsync()
 };