public async Task <IActionResult> GetAllToDoItems([FromQuery] PaginationParameters parameters) { long userId = long.Parse(HttpContext.Items["UserId"].ToString()); PagedList <ToDoItemDto> pagedToDoItemDto = await _toDoItemContract.GetToDoItems(parameters, userId); if (pagedToDoItemDto != null) { if (pagedToDoItemDto.Count > 0) { var metadata = new { pagedToDoItemDto.TotalCount, pagedToDoItemDto.PageSize, pagedToDoItemDto.CurrentPage, pagedToDoItemDto.TotalPages, pagedToDoItemDto.HasNext, pagedToDoItemDto.HasPrevious }; Response.Headers.Add("X-Pagination", JsonConvert.SerializeObject(metadata)); return(Ok( new ApiResponse <PagedList <ToDoItemDto> > { IsSuccess = true, Result = pagedToDoItemDto, Message = "Items retrieval successful." })); } else { return(Ok( new ApiResponse <string> { IsSuccess = false, Result = "No ToDoItem records present.", Message = " Please add few ToDoItems first." })); } } return(NotFound( new ApiResponse <string> { IsSuccess = false, Result = "No Results Found.", Message = "No data exist. Please add todo items first." })); }
public async Task GetToDoItems() { PagedList <ToDoItemDto> result = await _ToDoItemContract.GetToDoItems(paginationParameters, 1); Assert.IsNotNull(result); }