Skip to content

Commit

Permalink
Fixed SonarCloud issues
Browse files Browse the repository at this point in the history
  • Loading branch information
HlibBondarev committed Dec 25, 2024
1 parent fcafa62 commit e45390f
Showing 1 changed file with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1039,14 +1039,14 @@ public async Task UploadEmployeesForProvider(Guid id, UploadEmployeeDto[] data)
var errorMessage = "The number of entries to upload should be greater than 0.";
logger.LogError(errorMessage);
throw new InvalidOperationException(errorMessage);
};
}

if (data.Length > Constants.MaxNumberOfEmployeesToUpload)
{
var errorMessage = $"The number of entries should not exceed {Constants.MaxNumberOfEmployeesToUpload}.";
logger.LogError("The number of entries should not exceed {MaxNumberOfEmployeesToUpload}.", Constants.MaxNumberOfEmployeesToUpload);
throw new InvalidOperationException(errorMessage);
};
}

var uploadEmployeesRnokpps = data.Select(e => e.Rnokpp).ToList();

Expand All @@ -1056,7 +1056,7 @@ public async Task UploadEmployeesForProvider(Guid id, UploadEmployeeDto[] data)
var errorMessage = $"The Rnokpp property values are not unique.";
logger.LogError(errorMessage);
throw new InvalidOperationException(errorMessage);
};
}
#endregion

#region Transaction for loading employees into DB
Expand Down Expand Up @@ -1095,12 +1095,11 @@ async Task UploadEmployeesIntoDb()
//Cycle for filling the database with new employees
foreach (var key in uploadDictionary.Keys)
{
if (existingOfficialsForProvider.Contains(key))
// If this Employee already exists and occupies the same Position
if (existingOfficialsForProvider.Contains(key)
&& existingOfficialsForProvider[key].Select(o => o.Position.FullName).Contains(uploadDictionary[key].AssignedRole))
{
if (existingOfficialsForProvider[key].Select(o => o.Position.FullName).Contains(uploadDictionary[key].AssignedRole))
{
continue; // If this Employee already exists and occupies the same Position
}
continue;
}

// Create a new Position if it doesn't exist
Expand Down

0 comments on commit e45390f

Please sign in to comment.