Пример #1
0
 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())
     });
 }
Пример #2
0
        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);
        }
Пример #3
0
 public async Task <Response> Handle(Request request, CancellationToken cancellationToken)
 => new Response()
 {
     Note = NoteApiModel.FromNote(await _context.Notes.FindAsync(request.NoteId))
 };
Пример #4
0
 public async Task <Response> Handle(Request request, CancellationToken cancellationToken)
 => new Response()
 {
     Notes = await _context.Notes.Select(x => NoteApiModel.FromNote(x, true)).ToListAsync()
 };