mirror of
https://github.com/claunia/marechai.git
synced 2025-12-16 19:14:25 +00:00
Refactor ComputersController routes and method signatures for improved clarity and consistency
This commit is contained in:
@@ -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)]
|
||||||
|
|||||||
Reference in New Issue
Block a user