Skip to content

Commit

Permalink
Fix Null File Label exception
Browse files Browse the repository at this point in the history
  • Loading branch information
tom-karasch committed May 13, 2024
1 parent 3fd7be8 commit 7fda357
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
13 changes: 5 additions & 8 deletions FMS.Domain/Dto/Cabinet/CabinetExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,12 @@ namespace FMS.Domain.Dto
{
public static class CabinetExtensions
{
public static List<string> GetCabinetsForFile(this IEnumerable<CabinetSummaryDto> cabinets, string fileLabel, bool testValidity = true)
{
if (testValidity)
public static List<string> GetCabinetsForFile(this IEnumerable<CabinetSummaryDto> 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 =>
Expand Down
7 changes: 4 additions & 3 deletions FMS.Infrastructure/Repositories/FacilityRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,10 @@ public async Task<PaginatedList<FacilitySummaryDto>> 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();
Expand Down

0 comments on commit 7fda357

Please sign in to comment.