This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
};
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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 =>
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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++)
|
||||
{
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user