Exemple #1
0
        public async Task <IActionResult> GetTodos([FromQuery] int page = 1, [FromQuery] int pageSize = 5)
        {
            var result = await _todosService.FetchMany(page, pageSize);

            return(StatusCodeAndDtoWrapper.BuildSuccess(TodoListResponse.Build(result.Item2, Request.Path, page,
                                                                               pageSize, result.Item1)));
        }
        public async Task <JsonResult <List <TodoDto> > > GetCompleted()
        {
            var todos = await _todosService.FetchMany(TodoShow.Completed);

            return(Json(TodoListResponse.Build(todos),
                        GlobalConfiguration.Configuration.Formatters.JsonFormatter.SerializerSettings));
        }
        public async Task <ResponseMessageResult> GetPending()
        {
            var todos = await _todosService.FetchMany(TodoShow.Pending);

            return(ResponseMessage(Request.CreateResponse(HttpStatusCode.OK, TodoListResponse.Build(todos),
                                                          GlobalConfiguration.Configuration.Formatters.JsonFormatter)));
            // return Ok(TodoListResponse.Build(todos)); <-- also works
        }
Exemple #4
0
        public async Task <HttpResponseMessage> GetCompleted([FromUri] int page = 1, [FromUri] int pageSize = 5)
        {
            var result = await _todosService.FetchMany(page, pageSize, TodoShow.Completed);

            return(StatusCodeAndDtoWrapper.BuildSuccess(TodoListResponse.Build(result.Item2,
                                                                               Request.RequestUri.LocalPath, page,
                                                                               pageSize, result.Item1)));
        }
Exemple #5
0
        public async Task <IActionResult> GetTodos([FromQuery] int page = 1, [FromQuery] int pageSize = 5)
        {
            var result = await _mediator.Send(new GetTodosCommand
            {
                Page = page, PageSize = pageSize
            });

            return(StatusCodeAndDtoWrapper.BuildSuccess(TodoListResponse.Build(result.Item2, Request.Path, page,
                                                                               pageSize, result.Item1)));
        }