From 800cf932ca9f2d90a0da31a6119ca495941360d3 Mon Sep 17 00:00:00 2001 From: ngfrolov Date: Wed, 3 Aug 2022 11:13:23 +0500 Subject: [PATCH] fix `nullable warnings`. --- AsbCloudApp/Data/DailyReport/BhaDto.cs | 4 +-- AsbCloudApp/Data/TimeDto.cs | 25 +++++++++++++++++++ .../Services/DailyReport/CellAddress.cs | 16 ++++++------ .../DailyReport/DailyReportService.cs | 2 +- .../Detectors/DetectorFlashing.cs | 2 +- 5 files changed, 37 insertions(+), 12 deletions(-) diff --git a/AsbCloudApp/Data/DailyReport/BhaDto.cs b/AsbCloudApp/Data/DailyReport/BhaDto.cs index d858bd8c..681ae8a8 100644 --- a/AsbCloudApp/Data/DailyReport/BhaDto.cs +++ b/AsbCloudApp/Data/DailyReport/BhaDto.cs @@ -31,12 +31,12 @@ public string SluiceFinish { get; set; } /// - /// Подьем КНБК. Время начала + /// Подъем КНБК. Время начала /// public string ClimbBegin { get; set; } /// - /// Подьем КНБК. Время окончания + /// Подъем КНБК. Время окончания /// public string ClimbFinish { get; set; } diff --git a/AsbCloudApp/Data/TimeDto.cs b/AsbCloudApp/Data/TimeDto.cs index 6bb4b1e5..91d0fc5f 100644 --- a/AsbCloudApp/Data/TimeDto.cs +++ b/AsbCloudApp/Data/TimeDto.cs @@ -120,5 +120,30 @@ namespace AsbCloudApp.Data /// public int CompareTo(TimeDto other) => TotalSeconds - other.TotalSeconds; + + public override bool Equals(object obj) + { + if (ReferenceEquals(this, obj)) + { + return true; + } + + if (obj is null) + { + return false; + } + + if (obj is TimeDto objTime) + { + return objTime == this; + } + + return false; + } + + public override int GetHashCode() + { + return base.GetHashCode(); + } } } diff --git a/AsbCloudInfrastructure/Services/DailyReport/CellAddress.cs b/AsbCloudInfrastructure/Services/DailyReport/CellAddress.cs index cff2f920..92ec113f 100644 --- a/AsbCloudInfrastructure/Services/DailyReport/CellAddress.cs +++ b/AsbCloudInfrastructure/Services/DailyReport/CellAddress.cs @@ -136,12 +136,12 @@ namespace AsbCloudInfrastructure.Services.DailyReport return sb.ToString(); } - public bool Equals(IXLAddress x, IXLAddress y) - => x.ColumnNumber == y.ColumnNumber && - x.RowNumber == y.RowNumber && - x.FixedColumn == y.FixedColumn && - x.FixedRow == y.FixedRow && - x.Worksheet == y.Worksheet; + public bool Equals(IXLAddress? x, IXLAddress? y) + => x?.ColumnNumber == y?.ColumnNumber && + x?.RowNumber == y?.RowNumber && + x?.FixedColumn == y?.FixedColumn && + x?.FixedRow == y?.FixedRow && + x?.Worksheet == y?.Worksheet; public override int GetHashCode() => base.GetHashCode(); @@ -149,10 +149,10 @@ namespace AsbCloudInfrastructure.Services.DailyReport public int GetHashCode([DisallowNull] IXLAddress obj) => obj.GetHashCode(); - public bool Equals(IXLAddress other) + public bool Equals(IXLAddress? other) => Equals(this, other); - public override bool Equals(object obj) + public override bool Equals(object? obj) { if (ReferenceEquals(this, obj)) { diff --git a/AsbCloudInfrastructure/Services/DailyReport/DailyReportService.cs b/AsbCloudInfrastructure/Services/DailyReport/DailyReportService.cs index d29c4b34..a59cfc93 100644 --- a/AsbCloudInfrastructure/Services/DailyReport/DailyReportService.cs +++ b/AsbCloudInfrastructure/Services/DailyReport/DailyReportService.cs @@ -108,7 +108,7 @@ namespace AsbCloudInfrastructure.Services.DailyReport private async Task MakeDefaultDailyReportAsync(int idWell, DateTime date, CancellationToken token) { - var well = await wellService.GetAsync(idWell, token); + var well = await wellService.GetOrDefaultAsync(idWell, token); var dto = new DailyReportDto() { Head = new HeadDto() diff --git a/AsbCloudInfrastructure/Services/DetectOperations/Detectors/DetectorFlashing.cs b/AsbCloudInfrastructure/Services/DetectOperations/Detectors/DetectorFlashing.cs index 51efbf3a..844b975b 100644 --- a/AsbCloudInfrastructure/Services/DetectOperations/Detectors/DetectorFlashing.cs +++ b/AsbCloudInfrastructure/Services/DetectOperations/Detectors/DetectorFlashing.cs @@ -2,7 +2,7 @@ namespace AsbCloudInfrastructure.Services.DetectOperations.Detectors { - +#nullable enable /// /// Промывка перед наращиванием ///