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