public async Task <IActionResult> GetTasksListAsync(TaskFilter filter, ListOptions options, [FromServices] ITaskListQuery query)
        {
            try
            {
                if ((await _authorizationService.AuthorizeAsync(User, new Entities.Task(), Operations.Read)).Succeeded)
                {
                    var response = await query.RunAsync(filter, options);

                    return(Ok(response));
                }
                return(StatusCode(403, "Вы не можете просматривать задачи!"));
            }
            catch (WrongSortPropertyException ex)
            {
                return(BadRequest(ex.Message));
            }
        }
예제 #2
0
        public async Task <IActionResult> GetTask(Guid id, [FromServices] ITaskListQuery query)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            ListResponse <TaskResponse> response = await query.RunAsync(id);

            if (response.Items.Count > 0)
            {
                return(Ok(response));
            }
            else
            {
                return(NotFound(response));
            }
        }
예제 #3
0
        public async Task <IActionResult> GetTasksList([FromServices] ITaskListQuery query)
        {
            ListResponse <TaskResponse> response = await query.RunAsync();

            return(Ok(value: response));
        }