Skip to content

Commit a4d8003

Browse files
authored
Merge pull request #2095 from TechnologyEnhancedLearning/Develop/Fixes/TD-2408-NewCentreNameShouldNotBeSameAsExisting
TD-2408 Added a condition to check existing centre name
2 parents 630eaa0 + d0fb82b commit a4d8003

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

DigitalLearningSolutions.Web/Controllers/SuperAdmin/Centres/CentresController.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,12 @@ public IActionResult AddCentre()
418418
[Route("SuperAdmin/Centres/AddCentre")]
419419
public IActionResult AddCentre(AddCentreSuperAdminViewModel model)
420420
{
421+
var centres = centresDataService.GetAllCentres().ToList();
422+
bool isCentreNamePresent = centres.Any(center => center.Item2 == model.CentreName);
423+
if (isCentreNamePresent)
424+
{
425+
ModelState.AddModelError("CentreName", CommonValidationErrorMessages.CentreNameAlreadyExist);
426+
}
421427
if (!ModelState.IsValid)
422428
{
423429
var centreTypes = this.centresDataService.GetCentreTypes().ToList();

DigitalLearningSolutions.Web/Helpers/CommonValidationErrorMessages.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,6 @@ public static class CommonValidationErrorMessages
3333
public const string PasswordSimilarUsername = "Enter a password which is less similar to your user name";
3434
public const string PrimaryEmailInUseDuringDelegateRegistration =
3535
"A user with this email address is already registered";
36+
public const string CentreNameAlreadyExist = "The centre name you have entered already exists, please enter a different centre name";
3637
}
3738
}

0 commit comments

Comments
 (0)