Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions LearningHub.Nhs.WebUI/Controllers/LoginWizardController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,22 @@ public async Task<IActionResult> UpdateSecurityQuestionPost(MyAcountSecurityQues

if (model != null)
{
if ((model.SelectedFirstQuestionId == 0) || (model.SelectedSecondQuestionId == 0))
{
if (model.SelectedFirstQuestionId == 0)
{
this.ModelState.AddModelError(nameof(model.SelectedFirstQuestionId), CommonValidationErrorMessages.SecurityQuestionRequired);
}

if (model.SelectedSecondQuestionId == 0)
{
this.ModelState.AddModelError(nameof(model.SelectedSecondQuestionId), CommonValidationErrorMessages.SecurityQuestionRequired);
}

this.ViewBag.ReturnUrl = returnUrl;
return this.View("SecurityQuestionsDetails", securityViewModel);
}

if (model.SelectedFirstQuestionId == model.SelectedSecondQuestionId)
{
this.ModelState.AddModelError("DuplicateQuestion", CommonValidationErrorMessages.DuplicateQuestion);
Expand Down
111 changes: 79 additions & 32 deletions LearningHub.Nhs.WebUI/Controllers/MyAccountController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ public async Task<IActionResult> Index(string returnUrl = null, bool? checkDetai
/// <param name="checkDetails">Whether to check account details.</param>
/// <returns>IActionResult.</returns>
[HttpGet]
[Route("myaccount-employement")]
[Route("myaccount-employment")]
public async Task<IActionResult> MyEmploymentDetails(bool? checkDetails = false)
{
string loginWizardCacheKey = $"{this.CurrentUserId}:LoginWizard";
Expand Down Expand Up @@ -1003,25 +1003,36 @@ public async Task<IActionResult> ChangeCurrentRole([FromQuery] UserJobRoleUpdate
return this.View("ChangeCurrentRole", viewModel);
}

if (!string.IsNullOrWhiteSpace(viewModel.FilterText))
{
var jobRoles = await this.jobRoleService.GetPagedFilteredAsync(viewModel.FilterText, viewModel.CurrentPage, viewModel.PageSize);
viewModel.RoleList = jobRoles.Item2;
viewModel.TotalItems = jobRoles.Item1;
viewModel.HasItems = jobRoles.Item1 > 0;
}

if (formSubmission)
{
if (viewModel.SelectedJobRoleId.HasValue)
var hasSelectedJobRoleId = int.TryParse(viewModel.SelectedJobRoleId, out int currentRole);
if (hasSelectedJobRoleId && currentRole > 0)
{
var newRoleId = viewModel.SelectedJobRoleId.Value;
var newRoleId = currentRole;
var jobRole = await this.jobRoleService.GetByIdAsync(newRoleId);

if (jobRole.MedicalCouncilId > 0 && jobRole.MedicalCouncilId < 4)
{
return this.RedirectToAction(nameof(this.ChangeMedicalCouncilNo), new UserMedicalCouncilNoUpdateViewModel { SelectedJobRoleId = newRoleId });
}
else if (this.User.IsInRole("BasicUser"))
{
await this.userService.UpdateUserEmployment(
new elfhHub.Nhs.Models.Entities.UserEmployment
{
Id = profile.EmploymentId,
UserId = profile.Id,
JobRoleId = newRoleId,
GradeId = profile.GradeId,
SpecialtyId = profile.SpecialtyId,
StartDate = profile.JobStartDate,
LocationId = profile.LocationId,
});

this.ViewBag.SuccessMessage = CommonValidationErrorMessages.EmploymentDetailsUpdated;
this.ViewBag.MyAction = "MyEmploymentDetails";
return this.View("SuccessMessageMyAccount");
}
else
{
return this.RedirectToAction(nameof(this.ChangeGrade), new UserGradeUpdateViewModel { SelectedJobRoleId = newRoleId });
Expand All @@ -1030,9 +1041,24 @@ public async Task<IActionResult> ChangeCurrentRole([FromQuery] UserJobRoleUpdate
else
{
this.ModelState.AddModelError(nameof(viewModel.SelectedJobRoleId), CommonValidationErrorMessages.RoleRequired);
return this.View("ChangeCurrentRole", viewModel);
}
}
else
{
if (string.IsNullOrEmpty(viewModel.FilterText))
{
viewModel.FilterText = profile.JobRole;
viewModel.SelectedJobRoleId = profile.JobRoleId.HasValue ? profile.JobRoleId.ToString() : string.Empty;
}
}

if (!string.IsNullOrWhiteSpace(viewModel.FilterText))
{
var jobRoles = await this.jobRoleService.GetPagedFilteredAsync(viewModel.FilterText, viewModel.CurrentPage, viewModel.PageSize);
viewModel.RoleList = jobRoles.Item2;
viewModel.TotalItems = jobRoles.Item1;
viewModel.HasItems = jobRoles.Item1 > 0;
}

return this.View("ChangeCurrentRole", viewModel);
}
Expand Down Expand Up @@ -1075,24 +1101,25 @@ public async Task<IActionResult> ChangeMedicalCouncilNo([FromQuery] UserMedicalC
this.ModelState.AddModelError(nameof(viewModel.SelectedMedicalCouncilNo), validateMedicalCouncilNumber);
return this.View("ChangeMedicalCouncilNumber", viewModel);
}
else if (direct)
else if (this.User.IsInRole("BasicUser") || direct)
{
await this.userService.UpdateUserEmployment(
new elfhHub.Nhs.Models.Entities.UserEmployment
{
Id = profile.EmploymentId,
UserId = profile.Id,
JobRoleId = profile.JobRoleId,
MedicalCouncilId = viewModel.SelectedMedicalCouncilId,
MedicalCouncilNo = viewModel.SelectedMedicalCouncilNo,
GradeId = profile.GradeId,
SpecialtyId = profile.SpecialtyId,
StartDate = profile.JobStartDate,
LocationId = profile.LocationId,
});

this.ViewBag.SuccessMessage = "Your medical council number has been changed";
return this.View("SuccessMessage");
new elfhHub.Nhs.Models.Entities.UserEmployment
{
Id = profile.EmploymentId,
UserId = profile.Id,
JobRoleId = viewModel.SelectedJobRoleId,
MedicalCouncilId = viewModel.SelectedMedicalCouncilId,
MedicalCouncilNo = viewModel.SelectedMedicalCouncilNo,
GradeId = profile.GradeId,
SpecialtyId = profile.SpecialtyId,
StartDate = profile.JobStartDate,
LocationId = profile.LocationId,
});

this.ViewBag.SuccessMessage = CommonValidationErrorMessages.EmploymentDetailsUpdated;
this.ViewBag.MyAction = "MyEmploymentDetails";
return this.View("SuccessMessageMyAccount");
}
else
{
Expand All @@ -1111,6 +1138,13 @@ await this.userService.UpdateUserEmployment(
return this.View("ChangeMedicalCouncilNumber", viewModel);
}
}
else
{
if (string.IsNullOrEmpty(viewModel.SelectedMedicalCouncilNo))
{
viewModel.SelectedMedicalCouncilNo = profile.MedicalCouncilNo;
}
}

return this.View("ChangeMedicalCouncilNumber", viewModel);
}
Expand Down Expand Up @@ -1198,8 +1232,10 @@ public async Task<IActionResult> ChangePrimarySpecialty([FromQuery] UserPrimaryS

if (formSubmission)
{
if (viewModel.SelectedPrimarySpecialtyId.HasValue)
var hasSelectedPrimarySpeciality = int.TryParse(viewModel.SelectedPrimarySpecialtyId, out int selectedPrimarySpecialtyId);
if (hasSelectedPrimarySpeciality && selectedPrimarySpecialtyId > 0)
{
var newPrimarySpecialtyId = selectedPrimarySpecialtyId;
await this.userService.UpdateUserEmployment(
new elfhHub.Nhs.Models.Entities.UserEmployment
{
Expand All @@ -1209,7 +1245,7 @@ await this.userService.UpdateUserEmployment(
MedicalCouncilId = profile.MedicalCouncilId,
MedicalCouncilNo = profile.MedicalCouncilNo,
GradeId = profile.GradeId,
SpecialtyId = viewModel.SelectedPrimarySpecialtyId.Value,
SpecialtyId = newPrimarySpecialtyId,
StartDate = profile.JobStartDate,
LocationId = profile.LocationId,
});
Expand All @@ -1218,8 +1254,15 @@ await this.userService.UpdateUserEmployment(
}
else
{
this.ModelState.AddModelError(nameof(viewModel.SelectedPrimarySpecialtyId), CommonValidationErrorMessages.SpecialtyNotApplicable);
return this.View("ChangePrimarySpecialty", viewModel);
this.ModelState.AddModelError(nameof(viewModel.SelectedPrimarySpecialtyId), CommonValidationErrorMessages.SpecialtyRequired);
}
}
else
{
if (string.IsNullOrWhiteSpace(viewModel.FilterText))
{
viewModel.FilterText = profile.PrimarySpecialty;
viewModel.SelectedPrimarySpecialtyId = profile.SpecialtyId.HasValue ? profile.SpecialtyId.ToString() : string.Empty;
}
}

Expand Down Expand Up @@ -1274,6 +1317,10 @@ await this.userService.UpdateUserEmployment(
this.ModelState.Remove("Day");
this.ModelState.Remove("Month");
this.ModelState.Remove("Year");

viewModel.Day = profile.JobStartDate.HasValue ? profile.JobStartDate.Value.Day : null;
viewModel.Month = profile.JobStartDate.HasValue ? profile.JobStartDate.GetValueOrDefault().Month : null;
viewModel.Year = profile.JobStartDate.HasValue ? profile.JobStartDate.Value.Year : null;
}

return this.View("ChangeStartDate", viewModel);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,5 +254,10 @@ public static class CommonValidationErrorMessages
/// location Success Message.
/// </summary>
public const string PersonalDetailsSuccessMessage = "Your personal details has been changed";

/// <summary>
/// Security question Required.
/// </summary>
public const string SecurityQuestionRequired = "Please select a security question";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class UserJobRoleUpdateViewModel : PagingViewModel
/// <summary>
/// Gets or sets the selected job role id.
/// </summary>
public int? SelectedJobRoleId { get; set; }
public string SelectedJobRoleId { get; set; }

/// <summary>
/// Gets or sets the RoleList.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class UserPrimarySpecialtyUpdateViewModel : PagingViewModel
/// <summary>
/// Gets or sets the selected primary specialty id.
/// </summary>
public int? SelectedPrimarySpecialtyId { get; set; }
public string SelectedPrimarySpecialtyId { get; set; }

/// <summary>
/// Gets or sets the SpecialtyList.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,6 @@ public class UserStartDateUpdateViewModel : IValidatableObject
/// </summary>
public int? Year { get; set; }

/////// <summary>
/////// Gets or sets filter text.
/////// </summary>
////public string FilterText { get; set; }

/// <summary>
/// Gets or sets the selected primary specialty id.
/// </summary>
public int? SelectedPrimarySpecialtyId { get; set; }

/// <summary>
/// Gets or sets the GetDate.
/// </summary>
Expand Down
4 changes: 2 additions & 2 deletions LearningHub.Nhs.WebUI/Services/UserService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1212,7 +1212,7 @@ public async Task<UserProfileSummaryViewModel> GetUserProfileSummaryAsync()
if (employmentViewModel.JobRoleId.HasValue)
{
var job = await this.jobRoleService.GetByIdAsync(employmentViewModel.JobRoleId.Value);
viewModel.JobRole = job.Name;
viewModel.JobRole = job.NameWithStaffGroup;

if (employmentViewModel.GradeId.HasValue)
{
Expand Down Expand Up @@ -2008,7 +2008,7 @@ public async Task<MyAccountEmploymentDetailsViewModel> GetMyEmploymentDetailsAsy
if (employmentViewModel.JobRoleId.HasValue)
{
var job = await this.jobRoleService.GetByIdAsync(employmentViewModel.JobRoleId.Value);
viewModel.JobRole = job.Name;
viewModel.JobRole = job.NameWithStaffGroup;

if (employmentViewModel.GradeId.HasValue)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

@if (errorHasOccurred)
{
<vc:error-summary order-of-property-names="@(new[] { nameof(Model) })" />
<vc:error-summary order-of-property-names="@(new[] { nameof(Model.SelectedMedicalCouncilNo) })" />
}

<h1 class="nhsuk-heading-xl">Update medical council number</h1>
Expand Down Expand Up @@ -62,7 +62,7 @@

<div class="nhsuk-form-group">
<input type="hidden" name="SelectedJobRoleId" value="@Model.SelectedJobRoleId">
<input type="hidden" name="direct" value="@Context.Request.Query["direct"]">
@* <input type="hidden" name="direct" value="@Context.Request.Query["direct"]"> *@
<input type="hidden" name="formSubmission" value="true">
<button type="submit" class="nhsuk-button">Continue</button>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
hint-text=""
required="true"
css-class="nhsuk-u-width-two-thirds"
default-option=""
default-option="Please select a question"
select-list-options="@Model.FirstSecurityQuestions" />
</div>

Expand All @@ -60,7 +60,7 @@
hint-text=""
required="true"
css-class="nhsuk-u-width-two-thirds"
default-option=""
default-option="Please select a question"
select-list-options="@Model.SecondSecurityQuestions" />
</div>

Expand Down
Loading