Skip to content

Commit 4ebf27e

Browse files
authored
Merge pull request #2801 from TechnologyEnhancedLearning/Develop/Fix/TD-4645-Pattern-for-email-validation
TD-4645-Pattern for email validation updated in the SQL queries
2 parents 839cd64 + 8b8b281 commit 4ebf27e

File tree

4 files changed

+20
-20
lines changed

4 files changed

+20
-20
lines changed

DigitalLearningSolutions.Data/DataServices/CourseDataService.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ LEFT JOIN UserCentreDetails AS ucd WITH (NOLOCK) ON ucd.UserID = da.UserID AND u
153153
WHERE pr.CustomisationID = cu.CustomisationID
154154
AND can.CentreID = @centreId
155155
AND RemovedDate IS NULL
156-
AND COALESCE(ucd.Email, u.PrimaryEmail) LIKE '%_@_%.__%') AS DelegateCount";
156+
AND COALESCE(ucd.Email, u.PrimaryEmail) LIKE '%_@_%') AS DelegateCount";
157157

158158
private const string CompletedCountQuery =
159159
@"(SELECT COUNT(pr.CandidateID)
@@ -164,7 +164,7 @@ INNER JOIN dbo.Users AS u WITH (NOLOCK) ON u.ID = da.UserID
164164
LEFT JOIN UserCentreDetails AS ucd WITH (NOLOCK) ON ucd.UserID = da.UserID AND ucd.centreID = da.centreID
165165
WHERE pr.CustomisationID = cu.CustomisationID AND pr.Completed IS NOT NULL
166166
AND can.CentreID = @centreId
167-
AND COALESCE(ucd.Email, u.PrimaryEmail) LIKE '%_@_%.__%') AS CompletedCount";
167+
AND COALESCE(ucd.Email, u.PrimaryEmail) LIKE '%_@_%') AS CompletedCount";
168168

169169
private const string AllAttemptsQuery =
170170
@"(SELECT COUNT(aa.AssessAttemptID)
@@ -1124,7 +1124,7 @@ AND ap.DefaultContentTypeID <> 4
11241124
AND ((@answer3 IS NULL) OR ((@answer3 = 'No option selected' OR @answer3 = 'FREETEXTBLANKVALUE') AND (pr.Answer3 IS NULL OR LTRIM(RTRIM(pr.Answer3)) = ''))
11251125
OR ((@answer3 = 'FREETEXTNOTBLANKVALUE' AND pr.Answer3 IS NOT NULL AND LTRIM(RTRIM(pr.Answer3)) != '') OR (pr.Answer3 IS NOT NULL AND pr.Answer3 = @answer3)))
11261126
1127-
AND COALESCE(ucd.Email, u.PrimaryEmail) LIKE '%_@_%.__%'";
1127+
AND COALESCE(ucd.Email, u.PrimaryEmail) LIKE '%_@_%'";
11281128

11291129
string orderBy;
11301130
string sortOrder;
@@ -1632,7 +1632,7 @@ FROM DelegateAccounts AS da
16321632
WHERE da.CentreID = @centreId
16331633
AND p.CustomisationID = @customisationId
16341634
AND ap.DefaultContentTypeID <> 4
1635-
AND COALESCE(ucd.Email, u.PrimaryEmail) LIKE '%_@_%.__%'",
1635+
AND COALESCE(ucd.Email, u.PrimaryEmail) LIKE '%_@_%'",
16361636
new { customisationId, centreId }
16371637
);
16381638
}
@@ -1678,7 +1678,7 @@ AND ap.DefaultContentTypeID <> 4
16781678
AND ((@answer3 IS NULL) OR ((@answer3 = 'No option selected' OR @answer3 = 'FREETEXTBLANKVALUE') AND (pr.Answer3 IS NULL OR LTRIM(RTRIM(pr.Answer3)) = ''))
16791679
OR ((@answer3 = 'FREETEXTNOTBLANKVALUE' AND pr.Answer3 IS NOT NULL AND LTRIM(RTRIM(pr.Answer3)) != '') OR (pr.Answer3 IS NOT NULL AND pr.Answer3 = @answer3)))
16801680
1681-
AND COALESCE(ucd.Email, u.PrimaryEmail) LIKE '%_@_%.__%'";
1681+
AND COALESCE(ucd.Email, u.PrimaryEmail) LIKE '%_@_%'";
16821682

16831683

16841684
var mainSql = "SELECT COUNT(*) AS TotalRecords " + fromTableQuery;
@@ -1779,7 +1779,7 @@ AND ap.DefaultContentTypeID <> 4
17791779
AND ((@answer3 IS NULL) OR ((@answer3 = 'No option selected' OR @answer3 = 'FREETEXTBLANKVALUE') AND (pr.Answer3 IS NULL OR LTRIM(RTRIM(pr.Answer3)) = ''))
17801780
OR ((@answer3 = 'FREETEXTNOTBLANKVALUE' AND pr.Answer3 IS NOT NULL AND LTRIM(RTRIM(pr.Answer3)) != '') OR (pr.Answer3 IS NOT NULL AND pr.Answer3 = @answer3)))
17811781
1782-
AND COALESCE(ucd.Email, u.PrimaryEmail) LIKE '%_@_%.__%'";
1782+
AND COALESCE(ucd.Email, u.PrimaryEmail) LIKE '%_@_%'";
17831783

17841784
string orderBy;
17851785
string sortOrder;
@@ -1964,7 +1964,7 @@ FROM dbo.CandidateAssessments AS can WITH (NOLOCK)
19641964
INNER JOIN Users AS u WITH (NOLOCK) ON u.ID = can.DelegateUserID
19651965
LEFT JOIN UserCentreDetails AS ucd WITH (NOLOCK) ON ucd.UserID = u.ID AND ucd.centreID = can.CentreID
19661966
WHERE can.CentreID = @centreId AND can.SelfAssessmentID = csa.SelfAssessmentID
1967-
AND can.RemovedDate IS NULL AND COALESCE(ucd.Email, u.PrimaryEmail) LIKE '%_@_%.__%') AS DelegateCount,
1967+
AND can.RemovedDate IS NULL AND COALESCE(ucd.Email, u.PrimaryEmail) LIKE '%_@_%') AS DelegateCount,
19681968
(Select COUNT(*) FROM
19691969
(SELECT can.ID FROM dbo.CandidateAssessments AS can WITH (NOLOCK)
19701970
LEFT JOIN dbo.CandidateAssessmentSupervisors AS cas ON can.ID = cas.CandidateAssessmentID
@@ -2018,7 +2018,7 @@ FROM Customisations
20182018
WHERE CustomisationID = @customisationID ",
20192019
new { customisationId }).FirstOrDefault();
20202020

2021-
2021+
20222022
}
20232023
}
20242024
}

DigitalLearningSolutions.Data/DataServices/GroupsDataService.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ JOIN DelegateAccounts AS da WITH (NOLOCK) ON da.ID = gd.DelegateID
174174
JOIN Users AS u WITH (NOLOCK) ON u.ID = da.UserID
175175
LEFT JOIN UserCentreDetails AS ucd WITH (NOLOCK) ON ucd.UserID = u.ID AND ucd.CentreID = da.CentreID
176176
WHERE gd.GroupID = g.GroupID
177-
AND (u.PrimaryEmail like '%_@_%.__%' OR ucd.Email is NOT NULL)
177+
AND (u.PrimaryEmail like '%_@_%' OR ucd.Email is NOT NULL)
178178
AND da.Approved = 1 AND da.Active = 1) AS DelegateCount,
179179
({CourseCountSql}) AS CoursesCount,
180180
g.CreatedByAdminUserID AS AddedByAdminId,
@@ -213,7 +213,7 @@ public IEnumerable<Group> GetGroupsForCentre(int centreId)
213213
new { centreId }
214214
);
215215
}
216-
public IEnumerable<Group> GetGroupsForRegistrationResponse(int centreId, string? answer1, string? answer2, string? answer3, string? jobGroup, string? answer4, string? answer5, string? answer6)
216+
public IEnumerable<Group> GetGroupsForRegistrationResponse(int centreId, string? answer1, string? answer2, string? answer3, string? jobGroup, string? answer4, string? answer5, string? answer6)
217217
{
218218
return connection.Query<Group>(
219219
@$"{groupsSql}
@@ -337,7 +337,7 @@ FROM GroupDelegates AS gd
337337
JOIN Users AS u ON u.ID = da.UserID
338338
LEFT JOIN UserCentreDetails AS ucd ON ucd.UserID = u.ID AND ucd.CentreID = da.CentreID
339339
WHERE gd.GroupID = @groupId
340-
AND (u.PrimaryEmail like '%_@_%.__%' OR ucd.Email is NOT NULL)
340+
AND (u.PrimaryEmail like '%_@_%' OR ucd.Email is NOT NULL)
341341
AND da.Approved = 1 AND da.Active = 1",
342342
new { groupId }
343343
);

DigitalLearningSolutions.Data/DataServices/SelfAssessmentDataService/SelfAssessmentDataService.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ LEFT JOIN dbo.CandidateAssessmentSupervisorVerifications AS casv WITH (NOLOCK) O
247247
AND ((@isDelegateActive IS NULL) OR (@isDelegateActive = 1 AND (da.Active = 1)) OR (@isDelegateActive = 0 AND (da.Active = 0)))
248248
AND ((@removed IS NULL) OR (@removed = 1 AND (ca.RemovedDate IS NOT NULL)) OR (@removed = 0 AND (ca.RemovedDate IS NULL)))
249249
AND ((@submitted IS NULL) OR (@submitted = 1 AND (ca.SubmittedDate IS NOT NULL)) OR (@submitted = 0 AND (ca.SubmittedDate IS NULL)))
250-
AND COALESCE(ucd.Email, u.PrimaryEmail) LIKE '%_@_%.__%' ";
250+
AND COALESCE(ucd.Email, u.PrimaryEmail) LIKE '%_@_%' ";
251251

252252
var groupBy = $@" GROUP BY
253253
da.CandidateNumber,
@@ -382,7 +382,7 @@ LEFT JOIN dbo.CandidateAssessmentSupervisors AS cas WITH (NOLOCK) ON ca.ID = cas
382382
var whereQuery = $@" WHERE sa.ID = @selfAssessmentId
383383
AND da.CentreID = @centreID AND csa.CentreID = @centreID
384384
AND (ca.RemovedDate IS NULL)
385-
AND COALESCE(ucd.Email, u.PrimaryEmail) LIKE '%_@_%.__%' ";
385+
AND COALESCE(ucd.Email, u.PrimaryEmail) LIKE '%_@_%' ";
386386

387387
var groupBy = $@" GROUP BY
388388
da.CandidateNumber,
@@ -472,7 +472,7 @@ LEFT OUTER JOIN AdminAccounts AS aaEnrolledBy WITH (NOLOCK) ON aaEnrolledBy.ID =
472472
AND ((@isDelegateActive IS NULL) OR (@isDelegateActive = 1 AND (da.Active = 1)) OR (@isDelegateActive = 0 AND (da.Active = 0)))
473473
AND ((@removed IS NULL) OR (@removed = 1 AND (ca.RemovedDate IS NOT NULL)) OR (@removed = 0 AND (ca.RemovedDate IS NULL)))
474474
AND ((@submitted IS NULL) OR (@submitted = 1 AND (ca.SubmittedDate IS NOT NULL)) OR (@submitted = 0 AND (ca.SubmittedDate IS NULL)))
475-
AND COALESCE(ucd.Email, u.PrimaryEmail) LIKE '%_@_%.__%' ";
475+
AND COALESCE(ucd.Email, u.PrimaryEmail) LIKE '%_@_%' ";
476476

477477
var groupBy = $@" GROUP BY
478478
da.CandidateNumber,
@@ -576,7 +576,7 @@ LEFT OUTER JOIN AdminAccounts AS aaEnrolledBy WITH (NOLOCK) ON aaEnrolledBy.ID =
576576
AND ((@isDelegateActive IS NULL) OR (@isDelegateActive = 1 AND (da.Active = 1)) OR (@isDelegateActive = 0 AND (da.Active = 0)))
577577
AND ((@removed IS NULL) OR (@removed = 1 AND (ca.RemovedDate IS NOT NULL)) OR (@removed = 0 AND (ca.RemovedDate IS NULL)))
578578
AND ((@submitted IS NULL) OR (@submitted = 1 AND (ca.SubmittedDate IS NOT NULL)) OR (@submitted = 0 AND (ca.SubmittedDate IS NULL)))
579-
AND COALESCE(ucd.Email, u.PrimaryEmail) LIKE '%_@_%.__%' ";
579+
AND COALESCE(ucd.Email, u.PrimaryEmail) LIKE '%_@_%' ";
580580

581581
var groupBy = $@" GROUP BY
582582
da.CandidateNumber,

DigitalLearningSolutions.Data/DataServices/UserDataService/DelegateUserCardDataService.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ LEFT JOIN UserCentreDetails AS ucd WITH (NOLOCK) ON ucd.UserID = da.UserID AND u
187187
188188
AND Approved = 1
189189
190-
AND EmailAddress LIKE '%_@_%.__%'";
190+
AND EmailAddress LIKE '%_@_%'";
191191
public DelegateUserCard? GetDelegateUserCardById(int id)
192192
{
193193
var user = connection.Query<DelegateUserCard>(
@@ -224,15 +224,15 @@ public int GetCountDelegateUserCardsForExportByCentreId(String searchString, str
224224
{
225225
searchString = searchString.Trim();
226226
}
227-
227+
228228
if (groupId.HasValue)
229229
{
230230
var groupDelegatesForCentre = $@"SELECT DelegateID FROM GroupDelegates WHERE GroupID in (
231231
SELECT GroupID FROM Groups WHERE CentreID = @centreId AND RemovedDate IS NULL
232232
)";
233233
DelegatewhereConditon += "AND D.ID IN ( " + groupDelegatesForCentre + " AND GroupID = @groupId )";
234234
}
235-
235+
236236

237237
var delegateCountQuery = @$"SELECT COUNT(*) AS Matches FROM ( " + DelegateUserExportSelectQuery + " ) D " + DelegatewhereConditon;
238238

@@ -339,7 +339,7 @@ public List<DelegateUserCard> GetDelegateUserCardsForExportByCentreId(String sea
339339
)";
340340
if (groupId.HasValue)
341341
DelegatewhereConditon += "AND D.ID IN ( " + groupDelegatesForCentre + " AND GroupID = @groupId )";
342-
342+
343343

344344
string orderBy;
345345

@@ -424,7 +424,7 @@ public List<DelegateUserCard> GetDelegatesNotRegisteredForGroupByGroupId(int gro
424424
WHERE da.CentreId = @centreId
425425
AND da.Approved = 1
426426
AND da.Active = 1
427-
AND (u.PrimaryEmail like '%_@_%.__%' OR ucd.Email IS NOT NULL)
427+
AND (u.PrimaryEmail like '%_@_%' OR ucd.Email IS NOT NULL)
428428
AND NOT EXISTS (SELECT DelegateID FROM GroupDelegates WHERE DelegateID = da.ID
429429
AND GroupID = @groupId)",
430430
new

0 commit comments

Comments
 (0)