/// <summary>
        /// Returns the financial info of the participant.
        /// </summary>
        /// <param name="participantExchangeVisitor">The participant.</param>
        /// <returns>The financial info for the exchange visitor.</returns>
        public FinancialInfo GetFinancialInfo(ParticipantExchangeVisitor participantExchangeVisitor)
        {
            Contract.Requires(participantExchangeVisitor != null, "The participant exchange visitor must not be null.");
            var internationFundingDTO = ExchangeVisitorQueries.CreateGetInternationalFundingQuery(this.Context, participantExchangeVisitor.ParticipantId).FirstOrDefault();
            var usFundingDTO          = ExchangeVisitorQueries.CreateGetUSFundingQuery(this.Context, participantExchangeVisitor.ParticipantId).FirstOrDefault();

            return(GetFinancialInfo(participantExchangeVisitor, internationFundingDTO, usFundingDTO));
        }
        /// <summary>
        /// Returns the exchange visitor for the participant with the given id.
        /// </summary>
        /// <param name="user">The user requesting the exchange visitor.</param>
        /// <param name="projectId">The project id of the participant.</param>
        /// <param name="participantId">The id of the participant.</param>
        /// <returns>The exchange visitor model representing the participant.</returns>
        public async Task <ExchangeVisitor> GetExchangeVisitorAsync(int projectId, int participantId)
        {
            var participant = await Context.Participants.FindAsync(participantId);

            throwIfModelDoesNotExist(participantId, participant, typeof(Participant));
            throwIfParticipantIsNotAPerson(participant);

            var participantPerson = await Context.ParticipantPersons.FindAsync(participantId);

            throwIfModelDoesNotExist(participantId, participantPerson, typeof(ParticipantPerson));

            var participantExchangeVisitor = await CreateGetParticipantExchangeVisitorByParticipantIdQuery(participantId).FirstOrDefaultAsync();

            var project = await Context.Projects.FindAsync(participant.ProjectId);

            throwIfModelDoesNotExist(participant.ProjectId, project, typeof(Project));
            throwIfProjectIsNotExchangeVisitorType(participant, project);

            var biographyDto = await ExchangeVisitorQueries.CreateGetBiographicalDataByParticipantIdQuery(this.Context, participantId).FirstOrDefaultAsync();

            Contract.Assert(biographyDto != null, "The biography should not be null.");

            var subjectField = await ExchangeVisitorQueries.CreateGetSubjectFieldByParticipantIdQuery(this.Context, participantId).FirstOrDefaultAsync();

            var siteOfActivityAddress = GetStateDepartmentCStreetAddress();
            var person        = GetPerson(biography: biographyDto, participantExchangeVisitor: participantExchangeVisitor, subjectFieldDTO: subjectField, siteOfActivityAddress: siteOfActivityAddress);
            var financialInfo = await GetFinancialInfoAsync(participantExchangeVisitor);

            var dependents = await ExchangeVisitorQueries.CreateGetParticipantDependentsBiographicalQuery(this.Context, participantId).ToListAsync();

            var isExchangeVisitorValidated = await CreateGetValidatedSevisCommStatusesByParticipantId(participantId).CountAsync() > 0;

            return(GetExchangeVisitor(
                       isValidated: isExchangeVisitorValidated,
                       person: person,
                       financialInfo: financialInfo,
                       participantPerson: participantPerson,
                       occupationCategoryCode: null,
                       dependents: dependents,
                       siteOfActivity: siteOfActivityAddress,
                       sevisOrgId: project.SevisOrgId));
        }
Exemple #3
0
 private IQueryable <ReadyToValidateParticipantDTO> CreateGetReadyToValidationParticipantDTOByParticipantIdQuery(int participantId)
 {
     return(ExchangeVisitorQueries.CreateGetReadyToValidateParticipantDTOsQuery(this.Context, GetEarliestNeedsValidationInfoParticipantDate()).Where(x => x.ParticipantId == participantId));
 }
Exemple #4
0
 /// <summary>
 /// Returns a paged, filtered, sorterd collection of participants that have a sevis id and whose start date is at least 30 days away and are ready to start the sevis validation process.
 /// </summary>
 /// <param name="queryOperator">The query operator.</param>
 /// <returns>The participants that have a sevis id and whose start date has passed </returns>
 public Task <PagedQueryResults <ReadyToValidateParticipantDTO> > GetReadyToValidateParticipantsAsync(QueryableOperator <ReadyToValidateParticipantDTO> queryOperator)
 {
     return(ExchangeVisitorQueries.CreateGetReadyToValidateParticipantDTOsQuery(this.Context, GetEarliestNeedsValidationInfoParticipantDate(), queryOperator)
            .ToPagedQueryResultsAsync(queryOperator.Start, queryOperator.Limit));
 }