public SubmitApplicationSequenceHandler(IApplyRepository applyRepository, IContactQueryRepository contactQueryRepository, IEMailTemplateQueryRepository eMailTemplateQueryRepository, IMediator mediator)
 {
     _applyRepository              = applyRepository;
     _contactQueryRepository       = contactQueryRepository;
     _eMailTemplateQueryRepository = eMailTemplateQueryRepository;
     _mediator = mediator;
 }
Example #2
0
 public UpdateBatchCertificateHandler(ICertificateRepository certificateRepository, IContactQueryRepository contactQueryRepository, ILogger <UpdateBatchCertificateHandler> logger, IStandardService standardService)
 {
     _certificateRepository  = certificateRepository;
     _contactQueryRepository = contactQueryRepository;
     _logger          = logger;
     _standardService = standardService;
 }
Example #3
0
 public NotifyUserManagementUsersHandler(IEMailTemplateQueryRepository eMailTemplateQueryRepository, IContactQueryRepository contactQueryRepository, IMediator mediator, IOrganisationQueryRepository organisationQueryRepository)
 {
     _eMailTemplateQueryRepository = eMailTemplateQueryRepository;
     _contactQueryRepository       = contactQueryRepository;
     _mediator = mediator;
     _organisationQueryRepository = organisationQueryRepository;
 }
Example #4
0
 public ContactController(ILogger <ContactController> logger, IMediator mediator, IContactRepository contactRepository, IContactQueryRepository contactQueryRepository)
 {
     _logger                 = logger;
     _mediator               = mediator;
     _contactRepository      = contactRepository;
     _contactQueryRepository = contactQueryRepository;
 }
 public UpdateEpaOrganisationPrimaryContactHandler(IContactQueryRepository contactQueryRepository, ILogger <UpdateEpaOrganisationPrimaryContactHandler> logger,
                                                   IEMailTemplateQueryRepository eMailTemplateQueryRepository, IMediator mediator)
 {
     _contactQueryRepository = contactQueryRepository;
     _logger = logger;
     _eMailTemplateQueryRepository = eMailTemplateQueryRepository;
     _mediator = mediator;
 }
 public GetBatchCertificateHandler(ICertificateRepository certificateRepository, IContactQueryRepository contactQueryRepository, IStandardRepository standardRepository, IOrganisationQueryRepository organisationQueryRepository, ILogger <GetBatchCertificateHandler> logger)
 {
     _certificateRepository       = certificateRepository;
     _contactQueryRepository      = contactQueryRepository;
     _standardRepository          = standardRepository;
     _organisationQueryRepository = organisationQueryRepository;
     _logger = logger;
 }
 public ResetApplicationToStage1Handler(IApplyRepository applyRepository, IMediator mediator,
                                        IEMailTemplateQueryRepository eMailTemplateQueryRepository, IContactQueryRepository contactQueryRepository)
 {
     _applyRepository = applyRepository;
     _mediator        = mediator;
     _eMailTemplateQueryRepository = eMailTemplateQueryRepository;
     _contactQueryRepository       = contactQueryRepository;
 }
 public ReturnApplicationSequenceHandler(IApplyRepository applyRepository, IEMailTemplateQueryRepository eMailTemplateQueryRepository, IContactQueryRepository contactQueryRepository, IWebConfiguration config, IMediator mediator)
 {
     _applyRepository = applyRepository;
     _mediator        = mediator;
     _eMailTemplateQueryRepository = eMailTemplateQueryRepository;
     _contactQueryRepository       = contactQueryRepository;
     _config = config;
 }
 public CreateApplicationHandler(IOrganisationQueryRepository organisationQueryRepository,
                                 IRegisterQueryRepository registerQueryRepository, IContactQueryRepository contactQueryRepository,
                                 IApplyRepository applyRepository)
 {
     _applyRepository             = applyRepository;
     _organisationQueryRepository = organisationQueryRepository;
     _registerQueryRepository     = registerQueryRepository;
     _contactQueryRepository      = contactQueryRepository;
 }
Example #10
0
 public RequestForPrivilegeHandler(IMediator mediator, IContactQueryRepository contactQueryRepository,
                                   IOrganisationQueryRepository organisationQueryRepository, IWebConfiguration config, IContactRepository contactRepository)
 {
     _mediator = mediator;
     _contactQueryRepository      = contactQueryRepository;
     _organisationQueryRepository = organisationQueryRepository;
     _config            = config;
     _contactRepository = contactRepository;
 }
Example #11
0
 public RejectContactHandler(IContactQueryRepository contactQueryRepository,
                             IEMailTemplateQueryRepository eMailTemplateQueryRepository, IMediator mediator, IOrganisationQueryRepository organisationQueryRepository, IContactRepository contactRepository)
 {
     _contactQueryRepository       = contactQueryRepository;
     _eMailTemplateQueryRepository = eMailTemplateQueryRepository;
     _mediator = mediator;
     _organisationQueryRepository = organisationQueryRepository;
     _contactRepository           = contactRepository;
 }
 public ApproveContactHandler(IContactRepository contactRepository, IContactQueryRepository contactQueryRepository,
                              IEMailTemplateQueryRepository eMailTemplateQueryRepository, IMediator mediator, IWebConfiguration config, IOrganisationQueryRepository organisationQueryRepository)
 {
     _contactRepository            = contactRepository;
     _contactQueryRepository       = contactQueryRepository;
     _eMailTemplateQueryRepository = eMailTemplateQueryRepository;
     _mediator = mediator;
     _config   = config;
     _organisationQueryRepository = organisationQueryRepository;
 }
Example #13
0
 public InviteContactToOrganisationHandler(IContactQueryRepository contactQueryRepository,
                                           IContactRepository contactRepository,
                                           IMediator mediator, ISignInService signInService, IOrganisationQueryRepository organisationQueryRepository)
 {
     _contactQueryRepository = contactQueryRepository;
     _contactRepository      = contactRepository;
     _mediator      = mediator;
     _signInService = signInService;
     _organisationQueryRepository = organisationQueryRepository;
 }
Example #14
0
 public GetCertificatesToBeApprovedHandler(ICertificateRepository certificateRepository,
                                           IAssessmentOrgsApiClient assessmentOrgsApiClient,
                                           IContactQueryRepository contactQueryRepository,
                                           ILogger <GetCertificatesToBeApprovedHandler> logger)
 {
     _certificateRepository   = certificateRepository;
     _assessmentOrgsApiClient = assessmentOrgsApiClient;
     _contactQueryRepository  = contactQueryRepository;
     _logger = logger;
 }
Example #15
0
 public GetCertificatesToBeApprovedHandler(ICertificateRepository certificateRepository,
                                           IRoatpApiClient roatpApiClient,
                                           IContactQueryRepository contactQueryRepository,
                                           ILogger <GetCertificatesToBeApprovedHandler> logger)
 {
     _certificateRepository  = certificateRepository;
     _roatpApiClient         = roatpApiClient;
     _contactQueryRepository = contactQueryRepository;
     _logger = logger;
 }
Example #16
0
 public CreateBatchCertificateHandler(ICertificateRepository certificateRepository, IIlrRepository ilrRepository,
                                      IOrganisationQueryRepository organisationQueryRepository, IContactQueryRepository contactQueryRepository, ILogger <CreateBatchCertificateHandler> logger, IStandardService standardService, IRoatpApiClient roatpApiClient)
 {
     _certificateRepository       = certificateRepository;
     _ilrRepository               = ilrRepository;
     _organisationQueryRepository = organisationQueryRepository;
     _contactQueryRepository      = contactQueryRepository;
     _logger          = logger;
     _standardService = standardService;
     _roatpApiClient  = roatpApiClient;
 }
 public LoginHandler(ILogger <LoginHandler> logger,
                     IOrganisationQueryRepository organisationQueryRepository,
                     IContactQueryRepository contactQueryRepository, IContactRepository contactRepository,
                     IRegisterRepository registerRepository)
 {
     _logger = logger;
     _organisationQueryRepository = organisationQueryRepository;
     _contactQueryRepository      = contactQueryRepository;
     _contactRepository           = contactRepository;
     _registerRepository          = registerRepository;
 }
Example #18
0
 public CreateBatchCertificateHandler(ICertificateRepository certificateRepository, IIlrRepository ilrRepository, IAssessmentOrgsApiClient assessmentOrgsApiClient,
                                      IOrganisationQueryRepository organisationQueryRepository, IContactQueryRepository contactQueryRepository, ILogger <CreateBatchCertificateHandler> logger, IStandardService standardService)
 {
     _certificateRepository       = certificateRepository;
     _ilrRepository               = ilrRepository;
     _assessmentOrgsApiClient     = assessmentOrgsApiClient;
     _organisationQueryRepository = organisationQueryRepository;
     _contactQueryRepository      = contactQueryRepository;
     _logger          = logger;
     _standardService = standardService;
 }
 public ContactQueryController(IContactQueryRepository contactQueryRepository,
                               SearchOrganisationForContactsValidator searchOrganisationForContactsValidator,
                               IMediator mediator,
                               ILogger <ContactQueryController> logger, IWebConfiguration config)
 {
     _contactQueryRepository = contactQueryRepository;
     _logger = logger;
     _config = config;
     _searchOrganisationForContactsValidator = searchOrganisationForContactsValidator;
     _mediator = mediator;
 }
Example #20
0
 public CreateBatchCertificateHandler(ICertificateRepository certificateRepository, ILearnerRepository learnerRepository,
                                      IOrganisationQueryRepository organisationQueryRepository, IContactQueryRepository contactQueryRepository,
                                      ILogger <CreateBatchCertificateHandler> logger, IStandardService standardService, IProvidersRepository providersRepository)
 {
     _certificateRepository       = certificateRepository;
     _learnerRepository           = learnerRepository;
     _organisationQueryRepository = organisationQueryRepository;
     _contactQueryRepository      = contactQueryRepository;
     _logger              = logger;
     _standardService     = standardService;
     _providersRepository = providersRepository;
 }
        public SearchHandler(IOrganisationQueryRepository organisationRepository,
                             ILearnerRepository learnerRepository, ICertificateRepository certificateRepository, ILogger <SearchHandler> logger, IContactQueryRepository contactRepository, IStandardService standardService)
        {
            _organisationRepository = organisationRepository;
            _learnerRepository      = learnerRepository;
            _certificateRepository  = certificateRepository;
            _logger            = logger;
            _contactRepository = contactRepository;
            _standardService   = standardService;

            BuildAlternates();
        }
 public CreateContactHandler(
     IContactRepository contactRepository,
     IContactQueryRepository contactQueryRepository,
     ISignInService signInService,
     IMediator mediator, ILogger <CreateContactHandler> logger)
 {
     _contactRepository      = contactRepository;
     _contactQueryRepository = contactQueryRepository;
     _signInService          = signInService;
     _mediator = mediator;
     _logger   = logger;
 }
        public SearchHandler(IRegisterQueryRepository registerQueryRepository, IOrganisationQueryRepository organisationRepository,
                             IIlrRepository ilrRepository, ICertificateRepository certificateRepository, ILogger <SearchHandler> logger, IContactQueryRepository contactRepository, IStandardService standardService)
        {
            _registerQueryRepository = registerQueryRepository;
            _organisationRepository  = organisationRepository;
            _ilrRepository           = ilrRepository;
            _certificateRepository   = certificateRepository;
            _logger            = logger;
            _contactRepository = contactRepository;
            _standardService   = standardService;

            BuildAlternates();
        }
 public OrganisationStandardVersionOptInHandler(IOrganisationStandardRepository repository, IApplyRepository applyRepository, IStandardRepository standardRepository,
                                                IContactQueryRepository contactQueryRepository, IEMailTemplateQueryRepository eMailTemplateQueryRepository, IMediator mediator,
                                                IUnitOfWork unitOfWork, ILogger <OrganisationStandardVersionOptInHandler> logger)
 {
     _repository                   = repository;
     _applyRepository              = applyRepository;
     _standardRepository           = standardRepository;
     _contactQueryRepository       = contactQueryRepository;
     _eMailTemplateQueryRepository = eMailTemplateQueryRepository;
     _mediator   = mediator;
     _unitOfWork = unitOfWork;
     _logger     = logger;
 }
 public GetCertificatesHistoryHandler(ICertificateRepository certificateRepository,
                                      IRoatpApiClient roatpApiClient,
                                      IContactQueryRepository contactQueryRepository,
                                      ILogger <GetCertificatesHistoryHandler> logger)
 {
     _certificateRepository  = certificateRepository;
     _roatpApiClient         = roatpApiClient;
     _contactQueryRepository = contactQueryRepository;
     _logger         = logger;
     _ignoreStatuses = new List <string>
     {
         Domain.Consts.CertificateStatus.Deleted,
         Domain.Consts.CertificateStatus.Draft,
     };
 }
        public UpdateOrganisationRequestValidator(IStringLocalizer <UpdateOrganisationRequestValidator> localiser,
                                                  IContactQueryRepository contactQueryRepository,
                                                  IOrganisationQueryRepository organisationQueryRepository
                                                  )
        {
            _contactQueryRepository      = contactQueryRepository;
            _organisationQueryRepository = organisationQueryRepository;

            // ReSharper disable once LocalNameCapturedOnly
            UpdateOrganisationRequest updateOrganisationRequest;

            RuleFor(organisation => organisation.EndPointAssessorName).NotEmpty().WithMessage(
                string.Format(localiser[ResourceMessageName.MustBeDefined].Value,
                              nameof(updateOrganisationRequest.EndPointAssessorName).ToCamelCase()));

            RuleFor(organisation => organisation.PrimaryContact)
            .Custom((primaryContact, context) =>
            {
                if (string.IsNullOrEmpty(primaryContact))
                {
                    return;
                }

                var result = contactQueryRepository.CheckContactExists(primaryContact).Result;
                if (!result)
                {
                    context.AddFailure(new ValidationFailure("PrimaryContact",
                                                             string.Format(localiser[ResourceMessageName.DoesNotExist].Value, "PrimaryContact", primaryContact)));
                }
            });

            RuleFor(organisation => organisation.EndPointAssessorOrganisationId)
            .Custom((endPointAssessorOrganisationId, context) =>
            {
                var result = organisationQueryRepository.CheckIfAlreadyExists(endPointAssessorOrganisationId).Result;
                if (!result)
                {
                    context.AddFailure(new ValidationFailure("Organisation",
                                                             string.Format(localiser[ResourceMessageName.DoesNotExist].Value, "Organisation", endPointAssessorOrganisationId)));
                }
            });
        }
        public CreateOrganisationRequestValidator(IStringLocalizer <CreateOrganisationRequestValidator> localiser,
                                                  IContactQueryRepository contactQueryRepository,
                                                  IOrganisationQueryRepository organisationQueryRepository
                                                  )
        {
            _contactQueryRepository = contactQueryRepository;

            // ReSharper disable once LocalNameCapturedOnly
            CreateOrganisationRequest createOrganisationRequest;

            RuleFor(organisation => organisation.EndPointAssessorOrganisationId)
            .NotEmpty()
            .WithMessage(
                string.Format(localiser[ResourceMessageName.MustBeDefined].Value, nameof(createOrganisationRequest.EndPointAssessorOrganisationId).ToCamelCase()))
            .MaximumLength(12)
            // Please note we have to string.Format this due to limitation in Moq not handling Optional
            // Params
            .WithMessage(string.Format(localiser[ResourceMessageName.MaxLengthError].Value,
                                       nameof(createOrganisationRequest.EndPointAssessorOrganisationId), 12));

            RuleFor(organisation => organisation.EndPointAssessorName).NotEmpty().WithMessage(
                string.Format(localiser[ResourceMessageName.MustBeDefined].Value,
                              nameof(createOrganisationRequest.EndPointAssessorName).ToCamelCase()));

            RuleFor(organisation => organisation.EndPointAssessorUkprn).InclusiveBetween(10000000, 99999999)
            .WithMessage(localiser[ResourceMessageName.InvalidUkprn].Value);

            RuleFor(organisation => organisation.EndPointAssessorOrganisationId)
            .Custom((endPointAssessorOrganisationId, context) =>
            {
                var result = organisationQueryRepository.CheckIfAlreadyExists(endPointAssessorOrganisationId).Result;
                if (result)
                {
                    context.AddFailure(new ValidationFailure("Organisation",
                                                             string.Format(localiser[ResourceMessageName.AlreadyExists].Value, "Organisation")));
                }
            });
        }
 public void Setup()
 {
     Repository = MockRepository.GenerateMock<IContactQueryRepository>();
 }
Example #29
0
        public static SearchResult PopulateCertificateExtraInformationDependingOnPermission(this SearchResult searchResult,
                                                                                            SearchQuery request, IContactQueryRepository contactRepository,
                                                                                            Certificate certificate, Organisation searchingEpao, ILogger <SearchHandler> logger)
        {
            var createdLogEntry = certificate.CertificateLogs.FirstOrDefault(l => l.Status == CertificateStatus.Draft);

            var submittedLogEntry = certificate.CertificateLogs.Where(l => l.Action == CertificateActions.Submit)
                                    .OrderByDescending(l => l.EventTime)
                                    .FirstOrDefault();

            if (submittedLogEntry == null)
            {
                return(searchResult);
            }

            var submittingContact = contactRepository.GetContact(submittedLogEntry.Username).Result ?? contactRepository.GetContact(certificate.UpdatedBy).Result;
            var createdContact    = contactRepository.GetContact(createdLogEntry?.Username).Result ?? contactRepository.GetContact(certificate.CreatedBy).Result;

            var lastUpdatedLogEntry = certificate.CertificateLogs.Aggregate((i1, i2) => i1.EventTime > i2.EventTime ? i1 : i2) ?? submittedLogEntry;
            var lastUpdatedContact  = contactRepository.GetContact(lastUpdatedLogEntry.Username).Result;

            logger.LogInformation($"MatchUpExistingCompletedStandards After GetContact for CertificateId {certificate.Id}");

            var searchingContact = contactRepository.GetContact(request.Username).Result;

            var certificateData = JsonConvert.DeserializeObject <CertificateData>(certificate.CertificateData);

            var submittedCertificateData = JsonConvert.DeserializeObject <CertificateData>(submittedLogEntry.CertificateData);

            if (submittingContact != null && searchingContact != null && submittingContact.OrganisationId == searchingContact.OrganisationId)
            {
                searchResult.ShowExtraInfo = true;
                searchResult.OverallGrade  = GetSubmittedOrPreviousGrade(certificate, certificateData, submittedCertificateData);
                searchResult.SubmittedBy   = submittingContact.DisplayName;                                                              // This needs to be contact real name
                searchResult.SubmittedAt   = submittedLogEntry.EventTime.UtcToTimeZoneTime();                                            // This needs to be local time
                searchResult.AchDate       = GetSubmittedOrPreviousAchievementDate(certificate, certificateData, submittedCertificateData);
                searchResult.UpdatedBy     = lastUpdatedContact != null ? lastUpdatedContact.DisplayName : lastUpdatedLogEntry.Username; // This needs to be contact real name
                searchResult.UpdatedAt     = lastUpdatedLogEntry.EventTime.UtcToTimeZoneTime();                                          // This needs to be local time
            }
            else if (createdContact != null && searchingContact != null && createdContact.OrganisationId == searchingContact.OrganisationId)
            {
                searchResult.ShowExtraInfo = true;
                searchResult.OverallGrade  = GetSubmittedOrPreviousGrade(certificate, certificateData, submittedCertificateData);
                searchResult.SubmittedBy   = submittedLogEntry.Username;                                                                 // This needs to be contact real name
                searchResult.SubmittedAt   = submittedLogEntry.EventTime.UtcToTimeZoneTime();                                            // This needs to be local time
                searchResult.AchDate       = GetSubmittedOrPreviousAchievementDate(certificate, certificateData, submittedCertificateData);
                searchResult.UpdatedBy     = lastUpdatedContact != null ? lastUpdatedContact.DisplayName : lastUpdatedLogEntry.Username; // This needs to be contact real name
                searchResult.UpdatedAt     = lastUpdatedLogEntry.EventTime.UtcToTimeZoneTime();                                          // This needs to be local time
            }
            else if (certificate.OrganisationId == searchingEpao?.Id)
            {
                searchResult.ShowExtraInfo = true;
                searchResult.OverallGrade  = GetSubmittedOrPreviousGrade(certificate, certificateData, submittedCertificateData);
                searchResult.SubmittedBy   = submittedLogEntry.Username ?? certificate.UpdatedBy;
                searchResult.SubmittedAt   = submittedLogEntry.EventTime.UtcToTimeZoneTime(); // This needs to be local time
                searchResult.AchDate       = GetSubmittedOrPreviousAchievementDate(certificate, certificateData, submittedCertificateData);
                searchResult.UpdatedBy     = lastUpdatedLogEntry.Username ?? certificate.UpdatedBy;
                searchResult.UpdatedAt     = lastUpdatedLogEntry.EventTime.UtcToTimeZoneTime(); // This needs to be local time
            }
            else
            {
                searchResult.ShowExtraInfo  = false;
                searchResult.OverallGrade   = "";
                searchResult.SubmittedBy    = "";
                searchResult.SubmittedAt    = null;
                searchResult.LearnStartDate = null;
                searchResult.AchDate        = null;
                searchResult.UpdatedBy      = null;
                searchResult.UpdatedAt      = null;
            }

            return(searchResult);
        }
Example #30
0
        public static List <SearchResult> MatchUpExistingCompletedStandards(this List <SearchResult> searchResults, SearchQuery request, string likedSurname, IEnumerable <int> approvedStandards, ICertificateRepository certificateRepository, IContactQueryRepository contactRepository, IOrganisationQueryRepository _organisationRepository, ILogger <SearchHandler> logger)
        {
            logger.LogInformation("MatchUpExistingCompletedStandards Before Get Certificates for uln from db");
            var certificates = certificateRepository.GetDraftAndCompletedCertificatesFor(request.Uln).Result;

            logger.LogInformation("MatchUpExistingCompletedStandards After Get Certificates for uln from db");

            // Don't match up existing standards if paramters for filtering not passed in.
            if (string.IsNullOrWhiteSpace(likedSurname) || approvedStandards == null || approvedStandards.Count() == 0)
            {
                return(searchResults);
            }

            var searchingEpao = _organisationRepository.Get(request.EpaOrgId).Result;

            if (searchResults.Count > 0)
            {
                foreach (var searchResult in searchResults)
                {
                    var certificate = certificates.SingleOrDefault(s => s.StandardCode == searchResult.StdCode);

                    if (certificate != null)
                    {
                        var hasPreviousSubmission = certificate.CertificateLogs.Any(l => l.Action == CertificateActions.Submit);

                        if (hasPreviousSubmission)
                        {
                            searchResult.PopulateCertificateBasicInformation(certificate);
                            searchResult.PopulateCertificateExtraInformationDependingOnPermission(request, contactRepository, certificate, searchingEpao, logger);
                        }
                    }
                }
            }
            else if (certificates.Count > 0)
            {
                foreach (var certificate in certificates)
                {
                    // Don't return certficate if the EPAO isn't able to assess that standard
                    if (!approvedStandards.Contains(certificate.StandardCode))
                    {
                        continue;
                    }

                    var certificateData = JsonConvert.DeserializeObject <CertificateData>(certificate.CertificateData);

                    // Don't return certificate if the name does not match.
                    if (!string.Equals(certificateData.LearnerFamilyName.Trim(), likedSurname.Trim(), StringComparison.CurrentCultureIgnoreCase))
                    {
                        continue;
                    }

                    // Create a new search result as it would be when returned by the Learner record
                    var searchResult = new SearchResult
                    {
                        Uln            = certificate.Uln,
                        FamilyName     = certificateData.LearnerFamilyName,
                        GivenNames     = certificateData.LearnerGivenNames,
                        StdCode        = certificate.StandardCode,
                        UkPrn          = certificate.ProviderUkPrn,
                        CreatedAt      = certificate.CreatedAt,
                        LearnStartDate = certificateData.LearningStartDate
                    };

                    searchResult.PopulateCertificateBasicInformation(certificate);
                    searchResult.PopulateCertificateExtraInformationDependingOnPermission(request, contactRepository, certificate, searchingEpao, logger);

                    searchResults.Add(searchResult);
                }
            }

            return(searchResults);
        }
 public AccommodationLeadsController(IBus bus, IContactQueryRepository contactQueryRepository)
 {
     _bus = bus;
     _contactQueryRepository = contactQueryRepository;
 }
Example #32
0
 public AccommodationLeadApproved(IContactQueryRepository repository)
 {
     _repository = repository;
 }
 public void Setup()
 {
     _bus = MockRepository.GenerateMock<IBus>();
     _queryRepository = MockRepository.GenerateMock<IContactQueryRepository>();
     _controller = new AccommodationLeadsController(_bus, _queryRepository);
 }