public async Task <IActionResult> SearchNotesAsync([FromQuery] Client.Notes.NoteInfoSearchQuery query, CancellationToken cancellationToken)
        {
            cancellationToken.ThrowIfCancellationRequested();

            var modelQuery = NoteInfoSearchQueryConverter.Convert(query ?? new Client.Notes.NoteInfoSearchQuery());
            var modelNotes = await this.repository.SearchAsync(modelQuery, cancellationToken).ConfigureAwait(false);

            var clientNotes     = modelNotes.Select(note => NoteInfoConverter.Convert(note)).ToList();
            var clientNotesList = new Client.Notes.NoteList
            {
                Notes = clientNotes
            };

            return(this.Ok(clientNotesList));
        }
Example #2
0
        public async Task <IActionResult> SearchNotesAsync(
            [FromQuery] Client.Notes.NoteInfoSearchQuery clientQuery,
            CancellationToken cancellationToken)
        {
            cancellationToken.ThrowIfCancellationRequested();

            if (!this.TryGetSessionState(this.HttpContext.Request.Cookies, out var state))
            {
                return(this.Unauthorized());
            }

            var modelQuery = NoteInfoSearchQueryConverter.Convert(clientQuery ?? new Client.Notes.NoteInfoSearchQuery());

            modelQuery.UserId = state.UserId;
            var modelNotes = await this.repository.SearchAsync(modelQuery, cancellationToken).ConfigureAwait(false);

            var clientNotesList = modelNotes.Select(note => NoteInfoConverter.Convert(note)).ToList();

            return(this.Ok(clientNotesList));
        }