Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions test/CTS/AssessmentControllerTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ private static bool IsForbidResult<T>(ActionResult<T> a)
Assert.True(result != null || forbidResult != null);

}
catch (Exception)
catch (Xunit.Sdk.XunitException)
{
return false;
}
Expand All @@ -279,7 +279,7 @@ private static bool IsNotFoundResult<T>(ActionResult<T> a)
var result = a.Result as NotFoundResult;
Assert.Equal((int)HttpStatusCode.NotFound, result?.StatusCode);
}
catch (Exception)
catch (Xunit.Sdk.XunitException)
{
return false;
}
Expand Down
5 changes: 3 additions & 2 deletions test/ClinicalScheduler/EmailNotificationTest.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Microsoft.Data.SqlClient;
using Microsoft.EntityFrameworkCore;
using NSubstitute;
using NSubstitute.ExceptionExtensions;
Expand Down Expand Up @@ -281,7 +282,7 @@ await _context.Persons.AddAsync(new Models.ClinicalScheduler.Person
{
result = await _service.RemoveInstructorScheduleAsync(savedSchedule.InstructorScheduleId);
}
catch (Exception ex)
catch (Exception ex) when (ex is InvalidOperationException or DbUpdateException or SqlException or OperationCanceledException)
{
caughtException = ex;
System.Console.WriteLine($"Exception caught: {ex.GetType().Name}: {ex.Message}");
Expand Down Expand Up @@ -463,7 +464,7 @@ await _context.Persons.AddAsync(new Models.ClinicalScheduler.Person
{
result = await _service.RemoveInstructorScheduleAsync(savedPrimarySchedule.InstructorScheduleId);
}
catch (Exception ex)
catch (Exception ex) when (ex is InvalidOperationException or DbUpdateException or SqlException or OperationCanceledException)
{
caughtException = ex;
System.Console.WriteLine($"Exception caught: {ex.GetType().Name}: {ex.Message}");
Expand Down
2 changes: 1 addition & 1 deletion test/ClinicalScheduler/RotationServiceTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ private void SeedTestData()
}
_context.SaveChanges();
}
catch (Exception ex)
catch (Exception ex) when (ex is DbUpdateException or InvalidOperationException)
{
// Log the exception and provide a clear error message for debugging
Console.WriteLine($"Error seeding test data: {ex.Message}");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status403Forbidden)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
public async Task<IActionResult> GetClinicianSchedule(string mothraId, [FromQuery] int? year = null)

Check warning on line 125 in web/Areas/ClinicalScheduler/Controllers/CliniciansController.cs

View workflow job for this annotation

GitHub Actions / Backend Tests

'GetClinicianSchedule' has a cyclomatic complexity of '29'. Rewrite or refactor the code to decrease its complexity below '26'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1502)
{
var correlationId = HttpContext.TraceIdentifier ?? Guid.NewGuid().ToString();

Expand Down Expand Up @@ -201,7 +201,7 @@
fullName = $"Clinician {mothraId}",
firstName = "",
lastName = "",
role = (string?)null
role = default(string)
};
}
else
Expand Down
2 changes: 1 addition & 1 deletion web/Areas/Effort/Services/VerificationService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ await _auditService.LogRecordChangeAsync(

// Set verification timestamp
var verifiedDate = DateTime.Now;
var oldValues = new { EffortVerified = (DateTime?)null };
var oldValues = new { EffortVerified = default(DateTime?) };

instructor.EffortVerified = verifiedDate;

Expand Down
10 changes: 6 additions & 4 deletions web/Areas/Students/Services/PhotoExportService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -891,6 +891,8 @@ public PhotoExportService(
/// Loads all student photos upfront in parallel for faster export generation.
/// Returns a dictionary keyed by student MailId for quick lookup during rendering.
/// </summary>
private sealed record PhotoLookupResult(string MailId, byte[]? PhotoBytes);

private async Task<Dictionary<string, byte[]>> BatchLoadPhotosAsync(List<StudentPhoto> students)
{
var photoCache = new Dictionary<string, byte[]>();
Expand All @@ -903,22 +905,22 @@ private async Task<Dictionary<string, byte[]>> BatchLoadPhotosAsync(List<Student
try
{
var photoBytes = await _photoService.GetStudentPhotoAsync(s.MailId);
return new { MailId = s.MailId, PhotoBytes = (byte[]?)photoBytes };
return new PhotoLookupResult(s.MailId, photoBytes);
}
catch (IOException ex)
{
_logger.LogWarning(ex, "IO error loading photo for student {MailId}", LogSanitizer.SanitizeId(s.MailId));
return new { MailId = s.MailId, PhotoBytes = (byte[]?)null };
return new PhotoLookupResult(s.MailId, null);
}
catch (HttpRequestException ex)
{
_logger.LogWarning(ex, "HTTP error loading photo for student {MailId}", LogSanitizer.SanitizeId(s.MailId));
return new { MailId = s.MailId, PhotoBytes = (byte[]?)null };
return new PhotoLookupResult(s.MailId, null);
}
catch (InvalidOperationException ex)
{
_logger.LogWarning(ex, "Invalid operation loading photo for student {MailId}", LogSanitizer.SanitizeId(s.MailId));
return new { MailId = s.MailId, PhotoBytes = (byte[]?)null };
return new PhotoLookupResult(s.MailId, null);
}
});

Expand Down
7 changes: 5 additions & 2 deletions web/EmailTemplates/Views/Shared/_EmailLayout.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,14 @@
@* Use width attribute for Outlook, max-width for modern clients. Class for responsive override. *@
<table class="email-container" cellpadding="0" cellspacing="0" border="0" width="650" bgcolor="#ffffff" style="background-color: #ffffff; border: 1px solid #dee2e6; max-width: 650px; width: 100%;">
@* UC Davis Weill Header Image *@
@{
var baseUrl = ViewBag.BaseUrl as string;
}
<tr>
<td class="email-header" style="padding: 0; line-height: 0; font-size: 0;">
@if (!string.IsNullOrWhiteSpace((string?)ViewBag.BaseUrl))
@if (!string.IsNullOrWhiteSpace(baseUrl))
{
<img src="@(((string)ViewBag.BaseUrl).TrimEnd('/'))/images/email/email-header-weill.jpg"
<img src="@(baseUrl.TrimEnd('/'))/images/email/email-header-weill.jpg"
alt="UC Davis Weill School of Veterinary Medicine"
width="650"
style="display: block; width: 100%; max-width: 650px; height: auto; border: 0;" />
Expand Down
Loading