Skip to content

Commit d53be6a

Browse files
committed
Fix primitive problem and use Count result instead
1 parent 57315bf commit d53be6a

File tree

10 files changed

+25
-20
lines changed

10 files changed

+25
-20
lines changed

NorthwindCRUD/Controllers/CategoriesController.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,12 +107,12 @@ public ActionResult<PagedResultDto<CategoryDto>> GetCategoriesWithPage(
107107
/// </summary>
108108
/// <returns>Total count of categories as an integer.</returns>
109109
[HttpGet("GetCategoriesCount")]
110-
public ActionResult<int> GetCategoriesCount()
110+
public ActionResult<CountResultDto> GetCategoriesCount()
111111
{
112112
try
113113
{
114114
var count = categoryService.GetAllAsQueryable().Count();
115-
return Ok(count);
115+
return new CountResultDto() { Count = count };
116116
}
117117
catch (Exception error)
118118
{

NorthwindCRUD/Controllers/CustomersController.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,12 +107,12 @@ public ActionResult<PagedResultDto<CustomerDto>> GetCustomersWithPage(
107107
/// </summary>
108108
/// <returns>Total count of customers as an integer.</returns>
109109
[HttpGet("GetCustomersCount")]
110-
public ActionResult<int> GetCustomersCount()
110+
public ActionResult<CountResultDto> GetCustomersCount()
111111
{
112112
try
113113
{
114114
var count = customerService.GetAllAsQueryable().Count();
115-
return Ok(count);
115+
return new CountResultDto() { Count = count };
116116
}
117117
catch (Exception error)
118118
{

NorthwindCRUD/Controllers/EmployeesController.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,12 +110,12 @@ public ActionResult<PagedResultDto<EmployeeDto>> GetPagedEmployeesWithPage(
110110
/// </summary>
111111
/// <returns>Total count of employees as an integer.</returns>
112112
[HttpGet("GetEmployeesCount")]
113-
public ActionResult<int> GetEmployeesCount()
113+
public ActionResult<CountResultDto> GetEmployeesCount()
114114
{
115115
try
116116
{
117117
var count = employeeService.GetAllAsQueryable().Count();
118-
return Ok(count);
118+
return new CountResultDto() { Count = count };
119119
}
120120
catch (Exception error)
121121
{

NorthwindCRUD/Controllers/OrdersController.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@
55
using Microsoft.AspNetCore.Mvc;
66
using NorthwindCRUD.Models.DbModels;
77
using NorthwindCRUD.Models.Dtos;
8-
using NorthwindCRUD.Models.InputModels;
98
using NorthwindCRUD.Services;
10-
using Swashbuckle.AspNetCore.Annotations;
119

1210
[ApiController]
1311
[Route("[controller]")]
@@ -114,12 +112,12 @@ public ActionResult<PagedResultDto<OrderDto>> GetPagedOrdersWithPage(
114112
/// </summary>
115113
/// <returns>Total count of orders as an integer.</returns>
116114
[HttpGet("GetOrdersCount")]
117-
public ActionResult<int> GetOrdersCount()
115+
public ActionResult<CountResultDto> GetOrdersCount()
118116
{
119117
try
120118
{
121119
var count = orderService.GetAllAsQueryable().Count();
122-
return Ok(count);
120+
return new CountResultDto() { Count = count };
123121
}
124122
catch (Exception error)
125123
{

NorthwindCRUD/Controllers/ProductsController.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,12 +113,12 @@ public ActionResult<PagedResultDto<ProductDto>> GetPagedProductsWithPage(
113113
/// </summary>
114114
/// <returns>Total count of products as an integer.</returns>
115115
[HttpGet("GetProductsCount")]
116-
public ActionResult<int> GetProductsCount()
116+
public ActionResult<CountResultDto> GetProductsCount()
117117
{
118118
try
119119
{
120120
var count = productService.GetAllAsQueryable().Count();
121-
return Ok(count);
121+
return new CountResultDto() { Count = count };
122122
}
123123
catch (Exception error)
124124
{

NorthwindCRUD/Controllers/RegionsController.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,12 +108,12 @@ public ActionResult<PagedResultDto<RegionDto>> GetPagedRegionsWithPage(
108108
/// </summary>
109109
/// <returns>Total count of regions as an integer.</returns>
110110
[HttpGet("GetRegionsCount")]
111-
public ActionResult<int> GetRegionsCount()
111+
public ActionResult<CountResultDto> GetRegionsCount()
112112
{
113113
try
114114
{
115115
var count = regionService.GetAllAsQueryable().Count();
116-
return Ok(count);
116+
return new CountResultDto() { Count = count };
117117
}
118118
catch (Exception error)
119119
{

NorthwindCRUD/Controllers/ShippersController.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,12 +108,12 @@ public ActionResult<PagedResultDto<ShipperDto>> GetPagedShippersWithPage(
108108
/// </summary>
109109
/// <returns>Total count of shippers as an integer.</returns>
110110
[HttpGet("GetShippersCount")]
111-
public ActionResult<int> GetShippersCount()
111+
public ActionResult<CountResultDto> GetShippersCount()
112112
{
113113
try
114114
{
115115
var count = shipperService.GetAllAsQueryable().Count();
116-
return Ok(count);
116+
return new CountResultDto() { Count = count };
117117
}
118118
catch (Exception error)
119119
{

NorthwindCRUD/Controllers/SuppliersController.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,12 +108,12 @@ public ActionResult<PagedResultDto<SupplierDto>> GetPagedSuppliersWithPage(
108108
/// </summary>
109109
/// <returns>Total count of suppliers as an integer.</returns>
110110
[HttpGet("GetSuppliersCount")]
111-
public ActionResult<int> GetSuppliersCount()
111+
public ActionResult<CountResultDto> GetSuppliersCount()
112112
{
113113
try
114114
{
115115
var count = supplierService.GetAllAsQueryable().Count();
116-
return Ok(count);
116+
return new CountResultDto() { Count = count };
117117
}
118118
catch (Exception error)
119119
{

NorthwindCRUD/Controllers/TerritoriesController.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,12 +110,12 @@ public ActionResult<PagedResultDto<TerritoryDto>> GetPagedTerritoriesWithPage(
110110
/// </summary>
111111
/// <returns>Total count of territories as an integer.</returns>
112112
[HttpGet("GetTerritoriesCount")]
113-
public ActionResult<int> GetTerritoriesCount()
113+
public ActionResult<CountResultDto> GetTerritoriesCount()
114114
{
115115
try
116116
{
117117
var count = territoryService.GetAllAsQueryable().Count();
118-
return Ok(count);
118+
return new CountResultDto() { Count = count };
119119
}
120120
catch (Exception error)
121121
{
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
namespace NorthwindCRUD.Models.Dtos
2+
{
3+
public class CountResultDto
4+
{
5+
public int Count { get; set; }
6+
}
7+
}

0 commit comments

Comments
 (0)