public async Task <IActionResult> UpdateEnrollee(int enrolleeId, EnrolleeProfileViewModel enrolleeProfile, [FromQuery] bool beenThroughTheWizard) { var enrollee = await _enrolleeService.GetEnrolleeNoTrackingAsync(enrolleeId); if (enrollee == null) { return(NotFound(ApiResponse.Message($"Enrollee not found with id {enrolleeId}"))); } if (!User.CanEdit(enrollee)) { return(Forbid()); } // If the enrollee is not in the status of 'Editable', it cannot be updated if (!(await _enrolleeService.IsEnrolleeInStatusAsync(enrolleeId, StatusType.Editable))) { this.ModelState.AddModelError("Enrollee.CurrentStatus", "Enrollee can not be updated when the current status is not 'Editable'."); return(BadRequest(ApiResponse.BadRequest(this.ModelState))); } await _enrolleeService.UpdateEnrolleeAsync(enrolleeId, enrolleeProfile, beenThroughTheWizard); return(NoContent()); }
public async Task <IActionResult> UpdateEnrollee(int enrolleeId, EnrolleeUpdateModel enrollee, [FromQuery] bool beenThroughTheWizard) { var record = await _enrolleeService.GetPermissionsRecordAsync(enrolleeId); if (record == null) { return(NotFound(ApiResponse.Message($"Enrollee not found with id {enrolleeId}"))); } if (!record.EditableBy(User)) { return(Forbid()); } // If the enrollee is not in the status of 'Editable', it cannot be updated if (!(await _enrolleeService.IsEnrolleeInStatusAsync(enrolleeId, StatusType.Editable))) { ModelState.AddModelError("Enrollee.CurrentStatus", "Enrollee can not be updated when the current status is not 'Editable'."); return(BadRequest(ApiResponse.BadRequest(ModelState))); } enrollee.SetTokenProperties(User); await _enrolleeService.UpdateEnrolleeAsync(enrolleeId, enrollee, beenThroughTheWizard); return(NoContent()); }
public async Task SubmitApplicationAsync(int enrolleeId, EnrolleeUpdateModel updatedProfile) { var enrollee = await _context.Enrollees .Include(e => e.PhysicalAddress) .Include(e => e.MailingAddress) .Include(e => e.Certifications) .ThenInclude(c => c.License) .Include(e => e.Jobs) .Include(e => e.OboSites) .ThenInclude(s => s.PhysicalAddress) .Include(e => e.EnrolleeRemoteUsers) .Include(e => e.RemoteAccessSites) .ThenInclude(ras => ras.Site) .Include(e => e.RemoteAccessLocations) .ThenInclude(ral => ral.PhysicalAddress) .Include(e => e.EnrolleeCareSettings) .Include(e => e.EnrolleeHealthAuthorities) .Include(e => e.Agreements) .Include(e => e.SelfDeclarations) .Include(e => e.Submissions) .SingleOrDefaultAsync(e => e.Id == enrolleeId); bool minorUpdate = await _submissionRulesService.QualifiesAsMinorUpdateAsync(enrollee, updatedProfile); await _enrolleeService.UpdateEnrolleeAsync(enrolleeId, updatedProfile); if (minorUpdate) { return; } await _enrolleeSubmissionService.CreateEnrolleeSubmissionAsync(enrolleeId); enrollee.AddEnrolmentStatus(StatusType.UnderReview); await _businessEventService.CreateStatusChangeEventAsync(enrolleeId, "Submitted"); if (_httpContext.HttpContext.User.HasVCIssuance()) { try { await _verifiableCredentialService.RevokeCredentialsAsync(enrollee.Id); await _verifiableCredentialService.CreateConnectionAsync(enrollee); } catch (Exception ex) { _logger.LogError("Error occurred attempting to create a connection invitation through the Verifiable Credential agent: ${ex}", ex); } } await ProcessEnrolleeApplicationRules(enrolleeId); await _context.SaveChangesAsync(); }
public async Task <IActionResult> UpdateEnrollee(int enrolleeId, Enrollee enrollee, [FromQuery] bool beenThroughTheWizard = false) { if (enrollee == null) { this.ModelState.AddModelError("Enrollee", "Could not update the enrollee, the passed in Enrollee cannot be null."); return(BadRequest(new ApiBadRequestResponse(this.ModelState))); } if (enrollee == null || enrollee.Id == null) { this.ModelState.AddModelError("Enrollee.Id", "Enrollee Id is required to make updates."); return(BadRequest(new ApiBadRequestResponse(this.ModelState))); } if (enrolleeId != enrollee.Id) { this.ModelState.AddModelError("Enrollee.Id", "Enrollee Id does not match with the payload."); return(BadRequest(new ApiBadRequestResponse(this.ModelState))); } if (!_enrolleeService.EnrolleeExists(enrolleeId)) { return(NotFound(new ApiResponse(404, $"Enrollee not found with id {enrolleeId}"))); } // If the enrollee is not in the status of 'In Progress', it cannot be updated if (!(await _enrolleeService.IsEnrolleeInStatusAsync(enrolleeId, Status.IN_PROGRESS_CODE))) { this.ModelState.AddModelError("Enrollee.CurrentStatus", "Enrollee can not be updated when the current status is not 'In Progress'."); return(BadRequest(new ApiBadRequestResponse(this.ModelState))); } // If the user is not an ADMIN, make sure the enrolleeId matches the user, otherwise return not authorized if (!BelongsToEnrollee(enrollee)) { return(Forbid()); } await _enrolleeService.UpdateEnrolleeAsync(enrollee, beenThroughTheWizard); return(NoContent()); }