/// <summary> /// Set interview results and delete interview from list /// Also set to Candidate SUer status Passed or Rejected of Admission program /// </summary> /// <param name="candidateId">Id of Candidate User</param> /// <param name="status">Result of interview</param> /// <exception cref="CandidateDoesntExistsException">if candidate id doesn't exists</exception> public static void SetInterviewResults(int candidateId, InterviewStatus status) { CandidateUser candidate = UsersManager.GetUser <CandidateUser>(candidateId); if (candidate == null) { throw new CandidateDoesntExistsException(candidateId); } Instance._interviews.RemoveAll(n => n.CandidateID == candidateId); switch (status) { case InterviewStatus.Passed: candidate.Status = Passed; break; case InterviewStatus.Fail: candidate.Status = Rejected; break; default: throw new ArgumentOutOfRangeException(nameof(status), status, null); } }
private static SchoolAttended MapSchoolAttended(CandidateUser candidateUser, IDictionary <int, int> schoolAttendedIds, int candidateId) { if (candidateUser.Candidate.ApplicationTemplate?.EducationHistory == null) { return(null); } var educationHistory = candidateUser.Candidate.ApplicationTemplate.EducationHistory; if (string.IsNullOrEmpty(educationHistory.Institution) || educationHistory.FromYear == 0 || educationHistory.ToYear == 0) { return(null); } int schoolAttendedId; schoolAttendedIds.TryGetValue(candidateId, out schoolAttendedId); return(new SchoolAttended { SchoolAttendedId = schoolAttendedId, CandidateId = candidateId, SchoolId = null, OtherSchoolName = educationHistory.Institution, OtherSchoolTown = null, StartDate = new DateTime(educationHistory.FromYear, 1, 1), EndDate = new DateTime(educationHistory.ToYear, 1, 1), ApplicationId = null }); }
private int GetCandidateStatusTypeId(CandidateUser candidateUser) { switch (candidateUser.User.Status) { case 0: return(CandidateStatusTypeIdPreRegistered); case 10: return(CandidateStatusTypeIdPreRegistered); case 20: return(CandidateStatusTypeIdActivated); case 30: return(CandidateStatusTypeIdSuspended); case 90: return(CandidateStatusTypeIdSuspended); case 100: return(CandidateStatusTypeIdPendingDelete); case 999: return(CandidateStatusTypeIdDeleted); } return(CandidateStatusTypeIdPreRegistered); }
public CandidateWithHistory MapCandidateWithHistory(CandidateUser candidateUser, IDictionary <Guid, CandidateSummary> candidateSummaries, IDictionary <string, int> vacancyLocalAuthorities, IDictionary <int, int> localAuthorityCountyIds, IDictionary <int, int> schoolAttendedIds, IDictionary <int, Dictionary <int, int> > candidateHistoryIds, bool anonymise) { var candidatePerson = MapCandidatePerson(candidateUser, candidateSummaries, vacancyLocalAuthorities, localAuthorityCountyIds, schoolAttendedIds, anonymise); var candidateHistory = candidateUser.MapCandidateHistory(candidatePerson.Candidate.CandidateId, candidateHistoryIds); return(new CandidateWithHistory { CandidatePerson = candidatePerson, CandidateHistory = candidateHistory }); }
private CandidateUser GetCandidateUser(Guid candidateGuid) { var candidate = _candidateUserRepository.GetCandidate(candidateGuid); var user = _userRepository.GetUser(candidateGuid); var candidateUser = new CandidateUser { Candidate = candidate, User = user }; return(candidateUser); }
public IActionResult UpdateDetails([FromBody] ProfileSettings profile) { try { AppUser user = _appDbContext.Set <AppUser>().FirstOrDefault(u => u.Id == _clientData.Id); if (user != null) { _appDbContext.Attach(user); if (profile.FirstName != user.FirstName) { user.FirstName = profile.FirstName; } if (profile.LastName != user.LastName) { user.LastName = profile.LastName; } if (_clientData.UserType == (int)UserType.Candidate) { if (profile.AllowSendResume != null) { CandidateUser candidate = _appDbContext.Set <CandidateUser>().FirstOrDefault(u => u.Id == _clientData.ChildId); _appDbContext.Attach(candidate); candidate.AllowSendResume = (bool)profile.AllowSendResume; } } else if (_clientData.UserType == (int)UserType.Recruiter) { if (profile.ReceiveNotifications != null) { RecruiterUser recruiter = _appDbContext.Set <RecruiterUser>().FirstOrDefault(u => u.Id == _clientData.ChildId); _appDbContext.Attach(recruiter); recruiter.ReceiveNotifications = (bool)profile.ReceiveNotifications; } } _appDbContext.SaveChanges(); return(Ok()); } return(BadRequest("There was a problem updating details")); } catch (Exception e) { _log.LogError(e, "Update Details failed"); return(BadRequest(e)); } }
private async Task InitializeDataAsync() { IsBusy = true; var dataServices = new DataServices(); CandidateUser = new CandidateUser { AnswerTests = await dataServices.GetAnswerTestsAsync(), //CandidateUser = new CandidateUser() }; IsBusy = false; }
private int GetCandidateId(CandidateUser candidateUser, CandidateSummary candidateSummary) { var candidate = candidateUser.Candidate; if (candidateSummary.CandidateId != 0) { var candidateId = candidateSummary.CandidateId; if (candidateId > 0 && candidate.LegacyCandidateId != 0 && candidate.LegacyCandidateId != candidateId) { _logService.Warn($"CandidateId: {candidateId} does not match the LegacyCandidateId: {candidate.LegacyCandidateId} for candidate with Id: {candidate.Id}. This shouldn't change post activation"); } return(candidateId); } return(candidate.LegacyCandidateId); }
public PositionDto AddCandidateToPotentials(int positionId, int candidateId, CandidatePositionStatus status, string unregisteredUserFullName = "", string unregisteredEmail = "") { PositionDto positionDto = null; CandidatePosition candidatePosition = null; string email = unregisteredEmail; string fullName = unregisteredUserFullName; if (candidateId != -1) { var candidates = _context.Set <CandidateUser>().Where(c => c.Id.Equals(candidateId))?.Include(c => c.Identity); if (candidates != null && candidates.Count() > 0) { CandidateUser candidate = candidates.First(); fullName = $"{candidate.Identity.FirstName} {candidate.Identity.LastName}"; email = candidate.Identity.Email; } } candidatePosition = new CandidatePosition() { Email = email, FullName = fullName, PositionId = positionId, CandidateUserId = candidateId, Status = (int)status, }; var positions = _entities.Where(p => p.Id == positionId) .Include(p => p.PotentialCandidates); if (positions != null && positions.Count() > 0) { var position = positions.First(); position.PotentialCandidates.Add(candidatePosition); positionDto = Mapper.Map <PositionDto>(position); } return(positionDto); }
public async Task <IActionResult> RegisterCandidate([FromBody] CandidateRegistrationViewModel model) { try { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var userIdentity = _mapper.Map <AppUser>(model); var result = await _userManager.CreateAsync(userIdentity, model.Password); if (!result.Succeeded) { return(new BadRequestObjectResult(Errors.AddErrorsToModelState(result, ModelState))); } var candidate = new CandidateUser { IdentityId = userIdentity.Id }; await _appDbContext.Candidates.AddAsync(candidate); await _appDbContext.SaveChangesAsync(); userIdentity.ChildId = candidate.Id; userIdentity.UserType = (int)UserType.Candidate; await _userManager.UpdateAsync(userIdentity); await _appDbContext.SaveChangesAsync(); return(new OkResult()); } catch (Exception e) { return(BadRequest(e)); } }
public static IList <CandidateHistory> MapCandidateHistory(this CandidateUser candidateUser, int candidateId, IDictionary <int, Dictionary <int, int> > candidateHistoryIds) { var user = candidateUser.User; var candidateHistory = new List <CandidateHistory> { //Pre Registration GetCandidateHistory(candidateId, user.DateCreated, CandidateHistoryEventIdStatusChange, CandidateStatusTypeIdPreRegistered, candidateHistoryIds) }; if (user.Status >= 20 && (user.Status < 999 || candidateUser.User.ActivationDate.HasValue || candidateUser.Candidate.LegacyCandidateId != 0)) { //Activation candidateHistory.Add(GetCandidateHistory(candidateId, user.ActivationDate ?? user.DateCreated, CandidateHistoryEventIdStatusChange, CandidateStatusTypeIdActivated, candidateHistoryIds)); } if (user.Status >= 20) { //Note candidateHistory.Add(GetCandidateHistory(candidateId, user.ActivationDate ?? user.DateCreated, CandidateHistoryEventIdNote, 0, candidateHistoryIds)); } return(candidateHistory); }
public async Task <int> SendCandidateUserAsync(CandidateUser candidateUser) { var jsonCandidateTestRequest = JsonConvert.SerializeObject(candidateUser); HttpContent httpContent = new StringContent(jsonCandidateTestRequest); httpContent.Headers.ContentType = new MediaTypeHeaderValue("application/json"); try { using (var httpClient = new HttpClient()) { httpClient.DefaultRequestHeaders.Accept .Add(new MediaTypeWithQualityHeaderValue("application/json")); var response = await httpClient.PostAsync(new Uri(BaseUrl + "api/Tests"), httpContent); if (response.IsSuccessStatusCode) { var scoreJson = await response.Content.ReadAsStringAsync(); var score = JsonConvert.DeserializeObject <int>(scoreJson); return(score); } else { return(0); } } } catch (Exception) { return(0); } }
public CandidatePerson MapCandidatePerson(CandidateUser candidateUser, IDictionary <Guid, CandidateSummary> candidateSummaries, IDictionary <string, int> vacancyLocalAuthorities, IDictionary <int, int> localAuthorityCountyIds, IDictionary <int, int> schoolAttendedIds, bool anonymise) { try { var candidateGuid = candidateUser.Candidate.Id; var candidateSummary = candidateSummaries.ContainsKey(candidateGuid) ? candidateSummaries[candidateGuid] : new CandidateSummary(); var candidateId = GetCandidateId(candidateUser, candidateSummary); var address = candidateUser.Candidate.RegistrationDetails.Address; var email = candidateUser.Candidate.RegistrationDetails.EmailAddress.ToLower(); var monitoringInformation = candidateUser.Candidate.MonitoringInformation ?? new MonitoringInformation(); //TODO: Use PCA to validate these lookups when the service is complete and we have the keys var localAuthorityId = GetLocalAuthorityId(address.Postcode, vacancyLocalAuthorities); var countyId = localAuthorityCountyIds.ContainsKey(localAuthorityId) ? localAuthorityCountyIds[localAuthorityId] : 0; var candidate = new Candidate { CandidateId = candidateId, PersonId = candidateSummary.PersonId, CandidateStatusTypeId = GetCandidateStatusTypeId(candidateUser), DateofBirth = candidateUser.Candidate.RegistrationDetails.DateOfBirth, AddressLine1 = anonymise ? "" : address.AddressLine1, AddressLine2 = address.AddressLine2 ?? "", AddressLine3 = address.AddressLine3 ?? "", AddressLine4 = address.AddressLine4 ?? "", AddressLine5 = "", Town = "N/A", CountyId = countyId, Postcode = address.Postcode, LocalAuthorityId = localAuthorityId, Longitude = null, Latitude = null, GeocodeEasting = null, GeocodeNorthing = null, NiReference = "", VoucherReferenceNumber = null, UniqueLearnerNumber = null, UlnStatusId = 0, Gender = GetGender(monitoringInformation.Gender), EthnicOrigin = GetEthnicOrigin(monitoringInformation.Ethnicity), EthnicOriginOther = GetEthnicOriginOther(monitoringInformation.Ethnicity), ApplicationLimitEnforced = false, LastAccessedDate = candidateUser.User.LastLogin ?? candidateUser.Candidate.DateUpdated ?? candidateUser.Candidate.DateCreated, AdditionalEmail = anonymise ? candidateGuid + "@anon.com" : email.Length > 50 ? "" : email, Disability = GetDisability(monitoringInformation.DisabilityStatus), DisabilityOther = GetDisabilityOther(monitoringInformation.DisabilityStatus), HealthProblems = "", ReceivePushedContent = false, ReferralAgent = false, DisableAlerts = false, UnconfirmedEmailAddress = "", MobileNumberUnconfirmed = false, DoBFailureCount = null, ForgottenUsernameRequested = false, ForgottenPasswordRequested = false, TextFailureCount = 0, EmailFailureCount = 0, LastAccessedManageApplications = null, ReferralPoints = 0, BeingSupportedBy = "NAS Exemplar", LockedForSupportUntil = null, NewVacancyAlertEmail = null, NewVacancyAlertSMS = null, AllowMarketingMessages = GetAllowMarketingMessages(candidateUser.Candidate.CommunicationPreferences), ReminderMessageSent = true, CandidateGuid = candidateGuid }; var person = new Person { PersonId = candidateSummary.PersonId, Title = 0, OtherTitle = "", FirstName = anonymise ? "Candidate" : candidateUser.Candidate.RegistrationDetails.FirstName, MiddleNames = anonymise ? "" : candidateUser.Candidate.RegistrationDetails.MiddleNames, Surname = anonymise ? candidateGuid.ToString().Replace("-", "") : candidateUser.Candidate.RegistrationDetails.LastName, LandlineNumber = anonymise ? "07999999999" : candidateUser.Candidate.RegistrationDetails.PhoneNumber, MobileNumber = "", Email = anonymise ? candidateGuid + "@anon.com" : email, PersonTypeId = 1 }; return(new CandidatePerson { Candidate = candidate, SchoolAttended = MapSchoolAttended(candidateUser, schoolAttendedIds, candidateId), Person = person }); } catch (Exception ex) { //Copes with test data from integration and acceptance tests _logService.Error($"Failed to map Candidate with Id {candidateUser.Candidate.Id}", ex); return(null); } }