From b61808e0627828ef2efff4c6e11aaa07ffadb037 Mon Sep 17 00:00:00 2001 From: Olga Nemt Date: Fri, 14 Apr 2023 10:11:15 +0500 Subject: [PATCH] =?UTF-8?q?nullable=20enable=20(=D1=87=D0=B0=D1=81=D1=82?= =?UTF-8?q?=D1=8C=204)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AsbCloudInfrastructure/ReportDataSourcePgCloud.cs | 7 ++++++- AsbCloudInfrastructure/Startup.cs | 4 +++- 2 files changed, 9 insertions(+), 2 deletions(-) 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 }