From 7fda3571ecd7e1910b08497378b266b056e08b9e Mon Sep 17 00:00:00 2001 From: Tom Karasch Date: Mon, 13 May 2024 17:08:37 -0400 Subject: [PATCH] Fix Null File Label exception --- FMS.Domain/Dto/Cabinet/CabinetExtensions.cs | 13 +++++-------- .../Repositories/FacilityRepository.cs | 7 ++++--- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/FMS.Domain/Dto/Cabinet/CabinetExtensions.cs b/FMS.Domain/Dto/Cabinet/CabinetExtensions.cs index 3fb3f4a..3d3f0f4 100644 --- a/FMS.Domain/Dto/Cabinet/CabinetExtensions.cs +++ b/FMS.Domain/Dto/Cabinet/CabinetExtensions.cs @@ -8,15 +8,12 @@ namespace FMS.Domain.Dto { public static class CabinetExtensions { - public static List GetCabinetsForFile(this IEnumerable cabinets, string fileLabel, bool testValidity = true) - { - if (testValidity) + public static List GetCabinetsForFile(this IEnumerable cabinets, string fileLabel) + { + Prevent.NullOrEmpty(fileLabel, nameof(fileLabel)); + if (!File.IsValidFileLabelFormat(fileLabel)) { - Prevent.NullOrEmpty(fileLabel, nameof(fileLabel)); - if (!File.IsValidFileLabelFormat(fileLabel)) - { - throw new ArgumentException($"File label '{fileLabel}' is invalid.", nameof(fileLabel)); - } + throw new ArgumentException($"File label '{fileLabel}' is invalid.", nameof(fileLabel)); } return cabinets.Where(e => diff --git a/FMS.Infrastructure/Repositories/FacilityRepository.cs b/FMS.Infrastructure/Repositories/FacilityRepository.cs index d385726..5ff41a8 100644 --- a/FMS.Infrastructure/Repositories/FacilityRepository.cs +++ b/FMS.Infrastructure/Repositories/FacilityRepository.cs @@ -133,9 +133,10 @@ public async Task> GetFacilityPaginatedListAsy var cabinets = await _context.GetCabinetListAsync(false); foreach (var item in items) { - bool test = item.FacilityType.Name != "RN" || !item.FileLabel.IsNullOrEmpty(); - - item.Cabinets = cabinets.GetCabinetsForFile(item.FileLabel, test); + if (!item.FileLabel.IsNullOrEmpty()) + { + item.Cabinets = cabinets.GetCabinetsForFile(item.FileLabel); + } } var totalCount = await queried.CountAsync();