Skip to content

Commit 5663316

Browse files
committed
Email format validation added with Coalesce() in the sql query
1 parent f2b39c2 commit 5663316

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

DigitalLearningSolutions.Data/DataServices/CourseDataService.cs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,7 @@ LEFT JOIN UserCentreDetails AS ucd WITH (NOLOCK) ON ucd.UserID = da.UserID AND u
151151
WHERE pr.CustomisationID = cu.CustomisationID
152152
AND can.CentreID = @centreId
153153
AND RemovedDate IS NULL
154-
AND ((ucd.Email IS NOT NULL AND ucd.Email like '%_@_%.__%')
155-
OR u.PrimaryEmail like '%_@_%.__%')) AS DelegateCount";
154+
AND COALESCE(ucd.Email, u.PrimaryEmail) LIKE '%_@_%.__%') AS DelegateCount";
156155

157156
private const string CompletedCountQuery =
158157
@"(SELECT COUNT(pr.CandidateID)
@@ -163,8 +162,7 @@ INNER JOIN dbo.Users AS u WITH (NOLOCK) ON u.ID = da.UserID
163162
LEFT JOIN UserCentreDetails AS ucd WITH (NOLOCK) ON ucd.UserID = da.UserID AND ucd.centreID = da.centreID
164163
WHERE pr.CustomisationID = cu.CustomisationID AND pr.Completed IS NOT NULL
165164
AND can.CentreID = @centreId
166-
AND ((ucd.Email IS NOT NULL AND ucd.Email like '%_@_%.__%')
167-
OR u.PrimaryEmail like '%_@_%.__%')) AS CompletedCount";
165+
AND COALESCE(ucd.Email, u.PrimaryEmail) LIKE '%_@_%.__%') AS CompletedCount";
168166

169167
private const string AllAttemptsQuery =
170168
@"(SELECT COUNT(aa.AssessAttemptID)
@@ -1632,8 +1630,7 @@ FROM DelegateAccounts AS da
16321630
WHERE da.CentreID = @centreId
16331631
AND p.CustomisationID = @customisationId
16341632
AND ap.DefaultContentTypeID <> 4
1635-
AND ((ucd.Email IS NOT NULL AND ucd.Email like '%_@_%.__%')
1636-
OR u.PrimaryEmail like '%_@_%.__%')",
1633+
AND COALESCE(ucd.Email, u.PrimaryEmail) LIKE '%_@_%.__%'",
16371634
new { customisationId, centreId }
16381635
);
16391636
}

0 commit comments

Comments
 (0)