public async Task <IActionResult> SearchTasksAsync([FromQuery] ClientModels.Tasks.TaskInfoSearchQuery query, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); var userId = Guid.Parse(HttpContext.Items["userId"].ToString()); var modelQuery = TaskInfoSearchQueryConverter.Convert(query ?? new ClientModels.Tasks.TaskInfoSearchQuery()); var modelTasks = await tasks.SearchAsync(userId, modelQuery, cancellationToken); var clientTasks = modelTasks.Select(note => TaskInfoConverter.Convert(note)).ToList(); var clientTasksList = new ClientModels.Tasks.TaskList { Tasks = clientTasks }; return(Ok(clientTasksList)); }
public async Task <IActionResult> CreateTaskAsync([FromBody] ClientModels.Tasks.TaskCreationInfo creationInfo, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); if (creationInfo == null) { return(this.BadRequest()); } var userId = User.FindFirst(ClaimTypes.NameIdentifier).Value; //var userId = HttpContext.Items["userId"].ToString(); var modelCreationInfo = TaskCreateInfoConverter.Convert(userId, creationInfo); var modelTaskInfo = await this.tasks.CreateAsync(modelCreationInfo, cancellationToken); var clientTaskInfo = TaskInfoConverter.Convert(modelTaskInfo); var routeParams = new Dictionary <string, object> { { "taskId", clientTaskInfo.Id } }; return(this.CreatedAtRoute("GetTaskRoute", routeParams, clientTaskInfo)); }