public IHttpActionResult RemovePost(string postId, int pageNumber = 1, int pageSize = 0, string category = null) { object jsonObject; if (pageNumber <= 0 || pageSize < 0) { jsonObject = new { status = 500 }; return(Json(jsonObject)); } bool removeSuccessfully = postService.Remove(postId); if (!removeSuccessfully) { jsonObject = new { status = 500 }; } else { PaginationDTO <PostCardDTO> postCardPaginationDTO = postService.GetPostCardPagination(pageNumber, pageSize, category: category); APIPaginationModel <APIPostCardModel> postCardPaginationModel = dataMapper.MapPostCardPaginationDTOToModel(postCardPaginationDTO); jsonObject = new { status = 200, data = postCardPaginationModel }; } return(Json(jsonObject)); }
public IHttpActionResult GetPostCards(int pageSize, int pageNumber = 1, string category = null, string searchQuery = null) { object jsonObject; if (pageNumber <= 0 || pageSize < 0) { jsonObject = new { status = 500 }; return(Json(jsonObject)); } PaginationDTO <PostCardDTO> postCardPaginationDTO = postService.GetPostCardPagination(pageNumber, pageSize, category: category, searchQuery: searchQuery); if (postCardPaginationDTO == null) { jsonObject = new { status = 500 }; } else { APIPaginationModel <APIPostCardModel> postCardPaginationModel = dataMapper.MapPostCardPaginationDTOToModel(postCardPaginationDTO); jsonObject = new { status = 200, data = postCardPaginationModel }; } return(Json(jsonObject)); }