diff --git a/DigitalLearningSolutions.Data/DataServices/FrameworkDataService.cs b/DigitalLearningSolutions.Data/DataServices/FrameworkDataService.cs index a8bee31697..58ec21aa8a 100644 --- a/DigitalLearningSolutions.Data/DataServices/FrameworkDataService.cs +++ b/DigitalLearningSolutions.Data/DataServices/FrameworkDataService.cs @@ -130,7 +130,7 @@ bool zeroBased int InsertFrameworkCompetency(int competencyId, int? frameworkCompetencyGroupID, int adminId, int frameworkId); - int AddCollaboratorToFramework(int frameworkId, string userEmail, bool canModify); + int AddCollaboratorToFramework(int frameworkId, string userEmail, bool canModify, int? centreID); void AddCustomFlagToFramework(int frameworkId, string flagName, string flagGroup, string flagTagClass); void UpdateFrameworkCustomFlag(int frameworkId, int id, string flagName, string flagGroup, string flagTagClass); @@ -751,7 +751,7 @@ FROM FrameworkCollaborators fc ); } - public int AddCollaboratorToFramework(int frameworkId, string? userEmail, bool canModify) + public int AddCollaboratorToFramework(int frameworkId, string? userEmail, bool canModify, int? centreID) { if (userEmail is null || userEmail.Length == 0) { @@ -774,8 +774,8 @@ FROM FrameworkCollaborators } var adminId = (int?)connection.ExecuteScalar( - @"SELECT AdminID FROM AdminUsers WHERE Email = @userEmail AND Active = 1", - new { userEmail } + @"SELECT AdminID FROM AdminUsers WHERE Email = @userEmail AND Active = 1 AND CentreID = @centreID", + new { userEmail, centreID } ); if (adminId is null) { diff --git a/DigitalLearningSolutions.Web/Controllers/FrameworksController/Frameworks.cs b/DigitalLearningSolutions.Web/Controllers/FrameworksController/Frameworks.cs index bdaa3d4e20..7133838e07 100644 --- a/DigitalLearningSolutions.Web/Controllers/FrameworksController/Frameworks.cs +++ b/DigitalLearningSolutions.Web/Controllers/FrameworksController/Frameworks.cs @@ -166,7 +166,7 @@ public IActionResult CreateNewFramework(string actionname, int frameworkId = 0) var sessionNewFramework = multiPageFormService.GetMultiPageFormData( MultiPageFormDataFeature.AddNewFramework, TempData - ).GetAwaiter().GetResult(); + ).GetAwaiter().GetResult(); multiPageFormService.SetMultiPageFormData(sessionNewFramework, MultiPageFormDataFeature.AddNewFramework, TempData); detailFramework = sessionNewFramework.DetailFramework; } @@ -252,7 +252,7 @@ public IActionResult SaveNewFramework(string frameworkname, string actionname) { return StatusCode(500); } - var sessionNewFramework = multiPageFormService.GetMultiPageFormData(MultiPageFormDataFeature.AddNewFramework, TempData).GetAwaiter().GetResult(); + var sessionNewFramework = multiPageFormService.GetMultiPageFormData(MultiPageFormDataFeature.AddNewFramework, TempData).GetAwaiter().GetResult(); multiPageFormService.SetMultiPageFormData( sessionNewFramework, MultiPageFormDataFeature.AddNewFramework, @@ -641,7 +641,8 @@ public IActionResult AddCollaborators(string actionname, int frameworkId, bool e [Route("/Frameworks/Collaborators/{actionname}/{frameworkId}/")] public IActionResult AddCollaborator(string actionname, string userEmail, bool canModify, int frameworkId) { - var collaboratorId = frameworkService.AddCollaboratorToFramework(frameworkId, userEmail, canModify); + int? centreID = GetCentreId(); + var collaboratorId = frameworkService.AddCollaboratorToFramework(frameworkId, userEmail, canModify, centreID); if (collaboratorId > 0) { frameworkNotificationService.SendFrameworkCollaboratorInvite(collaboratorId, GetAdminId()); diff --git a/DigitalLearningSolutions.Web/Services/FrameworkService.cs b/DigitalLearningSolutions.Web/Services/FrameworkService.cs index 7ddb9b6169..9aa59127dd 100644 --- a/DigitalLearningSolutions.Web/Services/FrameworkService.cs +++ b/DigitalLearningSolutions.Web/Services/FrameworkService.cs @@ -124,7 +124,7 @@ bool zeroBased int InsertFrameworkCompetency(int competencyId, int? frameworkCompetencyGroupID, int adminId, int frameworkId); - int AddCollaboratorToFramework(int frameworkId, string userEmail, bool canModify); + int AddCollaboratorToFramework(int frameworkId, string userEmail, bool canModify, int? centreID); void AddCustomFlagToFramework(int frameworkId, string flagName, string flagGroup, string flagTagClass); void UpdateFrameworkCustomFlag(int frameworkId, int id, string flagName, string flagGroup, string flagTagClass); @@ -264,9 +264,9 @@ public FrameworkService(IFrameworkDataService frameworkDataService) this.frameworkDataService = frameworkDataService; } - public int AddCollaboratorToFramework(int frameworkId, string userEmail, bool canModify) + public int AddCollaboratorToFramework(int frameworkId, string userEmail, bool canModify, int? centreID) { - return frameworkDataService.AddCollaboratorToFramework(frameworkId, userEmail, canModify); + return frameworkDataService.AddCollaboratorToFramework(frameworkId, userEmail, canModify, centreID); } public void AddCompetencyAssessmentQuestion(int frameworkCompetencyId, int assessmentQuestionId, int adminId)