public IHttpActionResult GetAllProductSQL( int pageIndex = 1, int pageSize = 10) { long totalCount = 0; var data = _productService.GetAllProducts(pageIndex, pageSize, ref totalCount); var pagingRes = new PagingResult <ApiModels.Product.ProductModel> { Data = data.Select(x => new ApiModels.Product.ProductModel { Id = x.Id, Name = x.Name, Description = x.Description, IsActive = x.IsActive, CategoryID = x.CategoryID, CategoryName = x.CategoryName }).ToList(), TotalRecord = totalCount }; return(SuccessResult(data: pagingRes)); }
public IHttpActionResult GetAllCategory( int pageIndex = 1, int pageSize = 10) { long totalCount = 0; pageIndex = pageIndex > 0 ? pageIndex : 1; pageSize = pageSize > 0 ? pageSize : 10; var data = _categoryService.GetAllPaging(pageIndex, pageSize, ref totalCount); var pagingRes = new PagingResult <ApiModels.Category.CategoryModel> { Data = data.Select(x => new ApiModels.Category.CategoryModel { Id = x.Id, Name = x.Name, Url = x.Url }).ToList(), TotalRecord = totalCount, TotalPage = (int)Math.Ceiling((double)totalCount / pageSize) }; return(SuccessResult(data: pagingRes)); }