Use concrete types
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2025-06-24 19:28:55 +02:00
parent 8681247e76
commit ab32be98a6
20 changed files with 48 additions and 48 deletions

View File

@@ -65,7 +65,7 @@ public static class CreateCar
UserId = userId
};
var isDuplicate = await dbContext.Cars
bool isDuplicate = await dbContext.Cars
.AnyAsync(x => x.Name.ToUpper() == request.Name.ToUpper(), cancellationToken);
if (isDuplicate)

View File

@@ -21,7 +21,7 @@ public static class DeleteCar
ILoggerFactory loggerFactory,
CancellationToken cancellationToken)
{
var rows = await dbContext.Cars
int rows = await dbContext.Cars
.Where(x => x.Id == new CarId(id))
.ExecuteDeleteAsync(cancellationToken);
@@ -32,7 +32,7 @@ public static class DeleteCar
if (rows > 1)
{
var logger = loggerFactory.CreateLogger(nameof(DeleteCar));
ILogger logger = loggerFactory.CreateLogger(nameof(DeleteCar));
logger.LogWarning("Deleted '{DeletedRowCount}' rows for id '{CarId}'", rows, id);
}

View File

@@ -29,7 +29,7 @@ public static class GetCar
return TypedResults.NotFound();
}
var response = new Response(car.Id.Value, car.Name);
Response response = new Response(car.Id.Value, car.Name);
return TypedResults.Ok(response);
}
}

View File

@@ -38,7 +38,7 @@ public static class GetCars
.Select(x => new ResponseDto(x.Id.Value, x.Name))
.ToListAsync(cancellationToken);
var response = new ApiResponse
ApiResponse response = new ApiResponse
{
Cars = cars
};

View File

@@ -55,7 +55,7 @@ public static class UpdateCar
return TypedResults.NotFound();
}
var isDuplicate = await dbContext.Cars
bool isDuplicate = await dbContext.Cars
.AnyAsync(x => x.Name.ToUpper() == request.Name.ToUpper(), cancellationToken);
if (isDuplicate)

View File

@@ -121,7 +121,7 @@ public static class DependencyInjectionExtensions
.ValidateFluently()
.ValidateOnStart();
var jwtOptions = services.BuildServiceProvider().GetRequiredService<IOptions<JwtOptions>>();
IOptions<JwtOptions> jwtOptions = services.BuildServiceProvider().GetRequiredService<IOptions<JwtOptions>>();
services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
.AddJwtBearer(JwtBearerDefaults.AuthenticationScheme, o =>

View File

@@ -21,7 +21,7 @@ public static class DeleteConsumption
ILoggerFactory loggerFactory,
CancellationToken cancellationToken)
{
var rows = await dbContext.Consumptions
int rows = await dbContext.Consumptions
.Where(x => x.Id == new ConsumptionId(id))
.ExecuteDeleteAsync(cancellationToken);
@@ -32,7 +32,7 @@ public static class DeleteConsumption
if (rows > 1)
{
var logger = loggerFactory.CreateLogger(nameof(DeleteConsumption));
ILogger logger = loggerFactory.CreateLogger(nameof(DeleteConsumption));
logger.LogWarning("Deleted '{DeletedRowCount}' rows for id '{ConsumptionId}'", rows, id);
}

View File

@@ -59,7 +59,7 @@ public static class GetConsumptions
List<ResponseDto> responses = [];
foreach (var consumptions in consumptionsByCar.Select(x => x.Value))
foreach (List<Consumption> consumptions in consumptionsByCar.Select(x => x.Value))
{
for (int i = 0; i < consumptions.Count; i++)
{

View File

@@ -11,12 +11,12 @@ public class ApplyMigrationsService(
{
public async Task StartAsync(CancellationToken cancellationToken)
{
using var activity = activitySource.StartActivity("ApplyMigrations");
using Activity? activity = activitySource.StartActivity("ApplyMigrations");
logger.LogInformation("Starting migrations");
using IServiceScope scope = scopeFactory.CreateScope();
await using var dbContext = scope.ServiceProvider.GetRequiredService<ApplicationDbContext>();
await using ApplicationDbContext dbContext = scope.ServiceProvider.GetRequiredService<ApplicationDbContext>();
await dbContext.Database.MigrateAsync(cancellationToken);
}