diff --git a/AsbCloudInfrastructure/ReportDataSourcePgCloud.cs b/AsbCloudInfrastructure/ReportDataSourcePgCloud.cs index f85a3108..c32f426d 100644 --- a/AsbCloudInfrastructure/ReportDataSourcePgCloud.cs +++ b/AsbCloudInfrastructure/ReportDataSourcePgCloud.cs @@ -8,6 +8,7 @@ using System.Linq; namespace AsbCloudInfrastructure { +#nullable enable public class ReportDataSourcePgCloud : IReportDataSource { private readonly IAsbCloudDbContext context; @@ -37,6 +38,9 @@ namespace AsbCloudInfrastructure .Include(w => w.Telemetry) .FirstOrDefault(w => w.Id == idWell); + if(well is null) + throw new ArgumentInvalidException("idWell doesn`t exist", nameof(idWell)); + idTelemetry = well?.IdTelemetry; if (idTelemetry is null) throw new ArgumentInvalidException($"Well {idWell} doesn't contain telemetry", nameof(idWell)); @@ -49,7 +53,7 @@ namespace AsbCloudInfrastructure .Where(u => u.IdTelemetry == idTelemetry) .ToDictionary(u => u.IdUser, u => u); - timezoneOffset = well?.Telemetry?.Info?.TimeZoneOffsetTotalHours ?? well.Timezone?.Hours ?? 5.0; + timezoneOffset = well?.Telemetry?.Info?.TimeZoneOffsetTotalHours ?? well!.Timezone?.Hours ?? 5.0; info = new WellInfoReport { @@ -155,4 +159,5 @@ namespace AsbCloudInfrastructure public WellInfoReport GetWellInfo() => info; } +#nullable disable } diff --git a/AsbCloudInfrastructure/Startup.cs b/AsbCloudInfrastructure/Startup.cs index e93dc5e5..4ffdcf2f 100644 --- a/AsbCloudInfrastructure/Startup.cs +++ b/AsbCloudInfrastructure/Startup.cs @@ -13,6 +13,7 @@ using AsbCloudInfrastructure.Background; namespace AsbCloudInfrastructure { +#nullable enable public class Startup { public static void BeforeRunHandler(IHost host) @@ -20,7 +21,7 @@ namespace AsbCloudInfrastructure using var scope = host.Services.CreateScope(); var provider = scope.ServiceProvider; - var context = provider.GetService(); + var context = provider.GetRequiredService(); context.Database.SetCommandTimeout(TimeSpan.FromSeconds(2 * 60)); context.Database.Migrate(); @@ -70,4 +71,5 @@ namespace AsbCloudInfrastructure return bytes.ToString("### ### ###"); } } +#nullable disable }