Skip to content

Commit

Permalink
Merge pull request #256 from UKGovernmentBEIS/dvs-423-1a-dsit-2i-chec…
Browse files Browse the repository at this point in the history
…k-remove-whole-record-from-the-register

feat(remove-provider): email ids for 2i check filtered by profile
  • Loading branch information
JoeGLauria authored Jan 20, 2025
2 parents a2d6206 + 8d7e7a0 commit 4fbb5e5
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 10 deletions.
2 changes: 1 addition & 1 deletion DVSAdmin.BusinessLogic/Services/User/IUserService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ public interface IUserService
{
public Task<UserDto> GetUser(string email);

public Task<List<string>> GetUserEmailsExcludingLoggedIn(string loggedInUserEmail, string profile);
public Task<List<string>> GetUserEmailsExcludingLoggedIn(string loggedInUserEmail);
public Task UpdateUserProfile(string loggedInUserEmail, string profile);
}
}
4 changes: 2 additions & 2 deletions DVSAdmin.BusinessLogic/Services/User/UserService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ public async Task<UserDto> GetUser(string email)
UserDto userDto = automapper.Map<UserDto>(user);
return userDto;
}
public async Task<List<string>> GetUserEmailsExcludingLoggedIn(string loggedInUserEmail, string profile)
public async Task<List<string>> GetUserEmailsExcludingLoggedIn(string loggedInUserEmail)
{
var userEmails = await userRepository.GetUserEmailsExcludingLoggedIn(loggedInUserEmail, profile)?? new List<string>();
var userEmails = await userRepository.GetUserEmailsExcludingLoggedIn(loggedInUserEmail)?? new List<string>();
return userEmails;
}

Expand Down
2 changes: 1 addition & 1 deletion DVSAdmin.Data/Repositories/User/IUserRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public interface IUserRepository
{
public Task<GenericResponse> AddUser(User user);
public Task<User> GetUser(string email);
public Task<List<string>> GetUserEmailsExcludingLoggedIn(string loggedInUser, string profile);
public Task<List<string>> GetUserEmailsExcludingLoggedIn(string loggedInUser);
public Task UpdateUserProfile(string loggedInUserEmail, string profile);


Expand Down
6 changes: 3 additions & 3 deletions DVSAdmin.Data/Repositories/User/UserRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ public async Task<User> GetUser(string email)
return user;
}

public async Task<List<string>> GetUserEmailsExcludingLoggedIn(string loggedInUser, string profile)
public async Task<List<string>> GetUserEmailsExcludingLoggedIn(string loggedInUser)
{
List<string> userEmails = await context.User.Where(u => u.Email != loggedInUser && u.Profile == profile)
List<string> userEmails = await context.User.Where(u => u.Email != loggedInUser && u.Profile == "DSIT")
.Select(u => u.Email).ToListAsync()??new List<string>();
return userEmails;
}
Expand All @@ -70,7 +70,7 @@ public async Task UpdateUserProfile(string loggedInUserEmail, string profile)
try
{
var existingEntity = await context.User.FirstOrDefaultAsync(e => e.Email == loggedInUserEmail);
if (existingEntity != null && string.IsNullOrEmpty(existingEntity.Profile))
if (existingEntity != null && (string.IsNullOrEmpty(existingEntity.Profile) || existingEntity.Profile!= profile))
{
existingEntity.ModifiedDate = DateTime.UtcNow;
existingEntity.Profile = profile;
Expand Down
5 changes: 2 additions & 3 deletions DVSAdmin/Controllers/RegisterManagementController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ public class RegisterManagementController : Controller
private readonly ICertificateReviewService certificateReviewService;
private readonly IUserService userService;
private readonly IBucketService bucketService;
private string userEmail => HttpContext.Session.Get<string>("Email")??string.Empty;
private string userprofile => HttpContext.Session.Get<string>("Profile") ?? string.Empty;
private string userEmail => HttpContext.Session.Get<string>("Email")??string.Empty;
public RegisterManagementController(IRegManagementService regManagementService, ICertificateReviewService certificateReviewService, IUserService userService, IBucketService bucketService)
{

Expand Down Expand Up @@ -174,7 +173,7 @@ public async Task<IActionResult> ReasonForRemoval(int providerId)
public async Task<IActionResult> ProceedWithRemoval(int providerId, RemovalReasonsEnum? removalReason)
{
ProviderProfileDto providerProfileDto = await regManagementService.GetProviderDetails(providerId);
var userEmails = await userService.GetUserEmailsExcludingLoggedIn(userEmail, userprofile);
var userEmails = await userService.GetUserEmailsExcludingLoggedIn(userEmail);
if (removalReason == null)
{
ModelState.AddModelError("RemovalReason", "Select a reason for removal");
Expand Down

0 comments on commit 4fbb5e5

Please sign in to comment.