File tree Expand file tree Collapse file tree 2 files changed +7
-0
lines changed
DigitalLearningSolutions.Web
Controllers/SuperAdmin/Centres Expand file tree Collapse file tree 2 files changed +7
-0
lines changed Original file line number Diff line number Diff 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 ( ) ;
Original file line number Diff line number Diff 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}
You can’t perform that action at this time.
0 commit comments