Refactor ComputersController routes and method signatures for improved clarity and consistency

This commit is contained in:
2025-11-13 21:00:36 +00:00
parent 464f52878b
commit 27e5616da8

View File

@@ -40,14 +40,13 @@ namespace Marechai.Server.Controllers;
[ApiController]
public class ComputersController(MarechaiContext context) : ControllerBase
{
[HttpGet]
[HttpGet("/count")]
[AllowAnonymous]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status400BadRequest)]
public async Task<int> GetComputersCountAsync() =>
await context.Machines.CountAsync(c => c.Type == MachineType.Computer);
public Task<int> GetComputersCountAsync() => context.Machines.CountAsync(c => c.Type == MachineType.Computer);
[HttpGet]
[HttpGet("/minimum-year")]
[AllowAnonymous]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status400BadRequest)]
@@ -57,7 +56,7 @@ public class ComputersController(MarechaiContext context) : ControllerBase
t.Introduced.Value.Year > 1000)
.MinAsync(t => t.Introduced.Value.Year);
[HttpGet]
[HttpGet("/maximum-year")]
[AllowAnonymous]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status400BadRequest)]
@@ -67,7 +66,7 @@ public class ComputersController(MarechaiContext context) : ControllerBase
t.Introduced.Value.Year > 1000)
.MaxAsync(t => t.Introduced.Value.Year);
[HttpGet]
[HttpGet("/by-letter/{c}")]
[AllowAnonymous]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status400BadRequest)]
@@ -85,7 +84,7 @@ public class ComputersController(MarechaiContext context) : ControllerBase
})
.ToListAsync();
[HttpGet]
[HttpGet("/by-year/{year:int}")]
[AllowAnonymous]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status400BadRequest)]