Exemplo n.º 1
0
 private void DoDelete(
     DeletedParticipant deletedParticipant,
     Project project,
     Participant participant,
     ParticipantPerson person,
     ParticipantExchangeVisitor exchangeVisitor,
     IEnumerable <ParticipantPersonSevisCommStatus> statii,
     IEnumerable <MoneyFlow> participantSourceMoneyFlows,
     IEnumerable <MoneyFlow> participantRecipientMoneyFlows)
 {
     Contract.Requires(participant != null, "The participant must not be null.");
     Contract.Requires(project != null, "The project must not be null.");
     Context.ParticipantPersonSevisCommStatuses.RemoveRange(statii);
     Context.MoneyFlows.RemoveRange(participantSourceMoneyFlows);
     Context.MoneyFlows.RemoveRange(participantRecipientMoneyFlows);
     if (exchangeVisitor != null)
     {
         Context.ParticipantExchangeVisitors.Remove(exchangeVisitor);
     }
     if (person != null)
     {
         Context.ParticipantPersons.Remove(person);
     }
     Context.Participants.Remove(participant);
     deletedParticipant.Audit.SetHistory(project);
 }
        public void TestCreateGetParticipantPersonsSevisDTOByIdQuery()
        {
            var person = new Person
            {
                PersonId = 1,
                FullName = "full name"
            };
            var status = new ParticipantStatus
            {
                ParticipantStatusId = 1,
                Status = "status",
            };
            var participantType = new ParticipantType
            {
                IsPerson          = true,
                Name              = "part type",
                ParticipantTypeId = 90
            };
            var participant = new Participant
            {
                ParticipantId       = 1,
                Status              = status,
                ParticipantStatusId = status.ParticipantStatusId,
                ProjectId           = 250,
                ParticipantTypeId   = participantType.ParticipantTypeId,
                ParticipantType     = participantType,
                Person              = person,
                PersonId            = person.PersonId
            };

            var participantPerson = new ParticipantPerson
            {
                ParticipantId          = participant.ParticipantId,
                Participant            = participant,
                EndDate                = DateTimeOffset.UtcNow.AddDays(10.0),
                IsCancelled            = true,
                IsDS2019Printed        = true,
                IsDS2019SentToTraveler = true,
                IsSentToSevisViaRTI    = true,
                IsValidatedViaRTI      = true,
                SevisBatchResult       = "sevis batch result",
                SevisId                = "sevis id",
                SevisValidationResult  = "sevis validation result",
                StartDate              = DateTimeOffset.UtcNow.AddDays(-10.0)
            };

            participant.ParticipantPerson = participantPerson;

            context.People.Add(person);
            context.ParticipantTypes.Add(participantType);
            context.ParticipantStatuses.Add(status);
            context.Participants.Add(participant);
            context.ParticipantPersons.Add(participantPerson);

            var results = ParticipantPersonsSevisQueries.CreateGetParticipantPersonsSevisDTOByIdQuery(context, participant.ProjectId, participant.ParticipantId).ToList();

            Assert.AreEqual(1, results.Count());
        }
        public void TestCreateGetParticipantPersonSevisCommStatusesByParticipantIdQuery_Filtered()
        {
            var userAccount = new UserAccount
            {
                PrincipalId  = 100,
                DisplayName  = "display name",
                EmailAddress = "email"
            };
            var participant = new Participant
            {
                ParticipantId = 1,
                ProjectId     = 100
            };
            var participantPerson = new ParticipantPerson
            {
                ParticipantId = participant.ParticipantId,
                Participant   = participant
            };

            participant.ParticipantPerson = participantPerson;
            var sevisCommStatus = new SevisCommStatus
            {
                SevisCommStatusId   = 500,
                SevisCommStatusName = "sevis comm status name"
            };
            var status = new ParticipantPersonSevisCommStatus
            {
                Id                = 1,
                AddedOn           = DateTimeOffset.UtcNow,
                BatchId           = "batchId",
                ParticipantId     = participant.ParticipantId,
                ParticipantPerson = participantPerson,
                PrincipalId       = userAccount.PrincipalId,
                SevisCommStatus   = sevisCommStatus,
                SevisCommStatusId = sevisCommStatus.SevisCommStatusId,
                SevisOrgId        = "sevis org Id",
                SevisUsername     = "******"
            };

            context.UserAccounts.Add(userAccount);
            context.Participants.Add(participant);
            context.ParticipantPersons.Add(participantPerson);
            context.SevisCommStatuses.Add(sevisCommStatus);
            context.ParticipantPersonSevisCommStatuses.Add(status);

            var defaultSorter = new ExpressionSorter <ParticipantPersonSevisCommStatusDTO>(x => x.AddedOn, SortDirection.Descending);
            var filter        = new ExpressionFilter <ParticipantPersonSevisCommStatusDTO>(x => x.BatchId, ComparisonType.Equal, status.BatchId);
            var queryOperator = new QueryableOperator <ParticipantPersonSevisCommStatusDTO>(0, 1, defaultSorter);

            queryOperator.Filters.Add(filter);

            var results = ParticipantPersonsSevisQueries.CreateGetParticipantPersonSevisCommStatusesByParticipantIdQuery(context, participant.ProjectId, participant.ParticipantId, queryOperator);

            Assert.AreEqual(1, results.Count());
            var firstResult = results.First();

            Assert.AreEqual(status.Id, firstResult.Id);
        }
Exemplo n.º 4
0
        public void TestCreateGetSevisGroupedParticipantsQuery_CheckProperties()
        {
            var project = new Project
            {
                ProjectId = 1
            };
            var participant = new Participant
            {
                ParticipantId = 10,
                ProjectId     = project.ProjectId,
                Project       = project
            };
            var participantPerson = new ParticipantPerson
            {
                ParticipantId = participant.ParticipantId,
                Participant   = participant,
                SevisId       = "sevis id"
            };

            participant.ParticipantPerson = participantPerson;

            var status = new ParticipantPersonSevisCommStatus
            {
                Id                = 1,
                AddedOn           = DateTimeOffset.Now,
                ParticipantId     = participant.ParticipantId,
                ParticipantPerson = participantPerson,
                SevisCommStatusId = SevisCommStatus.QueuedToSubmit.Id,
                SevisOrgId        = "org",
                SevisUsername     = "******"
            };

            participantPerson.ParticipantPersonSevisCommStatuses.Add(status);

            context.Projects.Add(project);
            context.ParticipantPersons.Add(participantPerson);
            context.Participants.Add(participant);
            context.ParticipantPersonSevisCommStatuses.Add(status);

            var results = SevisBatchProcessingQueries.CreateGetSevisGroupedParticipantsQuery(context).ToList();

            Assert.AreEqual(1, results.Count);

            var firstResult = results.First();

            Assert.AreEqual(status.SevisOrgId, firstResult.SevisOrgId);
            Assert.AreEqual(status.SevisUsername, firstResult.SevisUsername);
            Assert.AreEqual(1, firstResult.Participants.Count());

            var firstParticipant = firstResult.Participants.First();

            Assert.AreEqual(participant.ParticipantId, firstParticipant.ParticipantId);
            Assert.AreEqual(project.ProjectId, firstParticipant.ProjectId);
            Assert.AreEqual(participantPerson.SevisId, firstParticipant.SevisId);
            Assert.AreEqual(status.SevisCommStatusId, firstParticipant.SevisCommStatusId);
        }
Exemplo n.º 5
0
        public void TestGetDS2019FileName()
        {
            var instance = new ParticipantPerson
            {
                ParticipantId = Int32.MaxValue,
                SevisId       = "N123456789"
            };

            Assert.AreEqual(string.Format(ParticipantPerson.DS2019_FILE_NAME_FORMAT_STRING, instance.ParticipantId, instance.SevisId), instance.GetDS2019FileName());
        }
Exemplo n.º 6
0
        public void TestCreateGetParticipantPersonsByBatchId_EnsureDistinct()
        {
            var batchId           = "batchId";
            var participantPerson = new ParticipantPerson
            {
                ParticipantId = 1
            };
            var readyToSubmit = new ParticipantPersonSevisCommStatus
            {
                Id = 1,
                SevisCommStatusId = SevisCommStatus.ReadyToSubmit.Id,
                ParticipantPerson = participantPerson,
                ParticipantId     = participantPerson.ParticipantId
            };
            var queuedToSubmit = new ParticipantPersonSevisCommStatus
            {
                Id = 2,
                SevisCommStatusId = SevisCommStatus.QueuedToSubmit.Id,
                ParticipantPerson = participantPerson,
                ParticipantId     = participantPerson.ParticipantId
            };
            var pendingSevisSend = new ParticipantPersonSevisCommStatus
            {
                Id = 3,
                SevisCommStatusId = SevisCommStatus.PendingSevisSend.Id,
                ParticipantPerson = participantPerson,
                ParticipantId     = participantPerson.ParticipantId,
                BatchId           = batchId
            };
            var otherBatchCommStatus = new ParticipantPersonSevisCommStatus
            {
                Id = 3,
                SevisCommStatusId = SevisCommStatus.SentToDhs.Id,
                ParticipantPerson = participantPerson,
                ParticipantId     = participantPerson.ParticipantId,
                BatchId           = batchId
            };

            participantPerson.ParticipantPersonSevisCommStatuses.Add(readyToSubmit);
            participantPerson.ParticipantPersonSevisCommStatuses.Add(queuedToSubmit);
            participantPerson.ParticipantPersonSevisCommStatuses.Add(pendingSevisSend);
            participantPerson.ParticipantPersonSevisCommStatuses.Add(otherBatchCommStatus);

            context.ParticipantPersons.Add(participantPerson);
            context.ParticipantPersonSevisCommStatuses.Add(readyToSubmit);
            context.ParticipantPersonSevisCommStatuses.Add(queuedToSubmit);
            context.ParticipantPersonSevisCommStatuses.Add(pendingSevisSend);
            context.ParticipantPersonSevisCommStatuses.Add(otherBatchCommStatus);
            var results = SevisBatchProcessingQueries.CreateGetParticipantPersonsByBatchId(context, batchId).ToList();

            Assert.AreEqual(1, results.Count);
            Assert.IsTrue(Object.ReferenceEquals(participantPerson, results.First()));
        }
        private ParticipantPerson DoCreateParticipantPerson(Participant participant, Audit audit)
        {
            var participantPerson = new ParticipantPerson();

            participantPerson.Participant = participant;

            var createAudit = new Create(audit.User);

            createAudit.SetHistory(participantPerson);
            this.Context.ParticipantPersons.Add(participantPerson);
            return(participantPerson);
        }
Exemplo n.º 8
0
        public void TestCreateGetSevisGroupedParticipantsQuery_CheckLatestSevisCommStatus()
        {
            var project = new Project
            {
                ProjectId = 1
            };
            var participant = new Participant
            {
                ParticipantId = 10,
                ProjectId     = project.ProjectId,
                Project       = project
            };
            var participantPerson = new ParticipantPerson
            {
                ParticipantId = participant.ParticipantId,
                Participant   = participant,
                SevisId       = "sevis id"
            };

            participant.ParticipantPerson = participantPerson;

            var status1 = new ParticipantPersonSevisCommStatus
            {
                Id                = 1,
                AddedOn           = DateTimeOffset.Now.AddDays(-1.0),
                ParticipantId     = participant.ParticipantId,
                ParticipantPerson = participantPerson,
                SevisCommStatusId = SevisCommStatus.ReadyToSubmit.Id
            };
            var status2 = new ParticipantPersonSevisCommStatus
            {
                Id                = 2,
                AddedOn           = DateTimeOffset.Now.AddDays(1.0),
                ParticipantId     = participant.ParticipantId,
                ParticipantPerson = participantPerson,
                SevisCommStatusId = SevisCommStatus.QueuedToSubmit.Id
            };

            participantPerson.ParticipantPersonSevisCommStatuses.Add(status1);
            participantPerson.ParticipantPersonSevisCommStatuses.Add(status2);

            context.Projects.Add(project);
            context.ParticipantPersons.Add(participantPerson);
            context.Participants.Add(participant);
            context.ParticipantPersonSevisCommStatuses.Add(status1);

            var results = SevisBatchProcessingQueries.CreateGetSevisGroupedParticipantsQuery(context).ToList();

            Assert.AreEqual(1, results.Count);
        }
        public void TestCreateGetParticipantPersonSevisCommStatusesQuery_DoesNotHaveUserAccount()
        {
            var participant = new Participant
            {
                ParticipantId = 1,
                ProjectId     = 100
            };
            var participantPerson = new ParticipantPerson
            {
                ParticipantId = participant.ParticipantId,
                Participant   = participant
            };

            participant.ParticipantPerson = participantPerson;
            var sevisCommStatus = new SevisCommStatus
            {
                SevisCommStatusId   = 500,
                SevisCommStatusName = "sevis comm status name"
            };
            var status = new ParticipantPersonSevisCommStatus
            {
                Id                = 1,
                AddedOn           = DateTimeOffset.UtcNow,
                BatchId           = "batchId",
                ParticipantId     = participant.ParticipantId,
                ParticipantPerson = participantPerson,
                PrincipalId       = null,
                SevisCommStatus   = sevisCommStatus,
                SevisCommStatusId = sevisCommStatus.SevisCommStatusId,
                SevisOrgId        = "sevis org Id",
                SevisUsername     = "******"
            };

            context.Participants.Add(participant);
            context.ParticipantPersons.Add(participantPerson);
            context.SevisCommStatuses.Add(sevisCommStatus);
            context.ParticipantPersonSevisCommStatuses.Add(status);

            var results = ParticipantPersonsSevisQueries.CreateGetParticipantPersonSevisCommStatusesQuery(context);

            Assert.AreEqual(1, results.Count());
            var firstResult = results.First();

            Assert.IsNull(firstResult.EmailAddress);
            Assert.IsNull(firstResult.DisplayName);
            Assert.IsNull(firstResult.PrincipalId);
        }
        public void TestCreateGetSimpleParticipantPersonsDTOQuery_CheckProperties()
        {
            var participantPerson = new ParticipantPerson
            {
                ParticipantId            = 1,
                SevisId                  = "N0000000001",
                HomeInstitutionAddressId = 3,
                HostInstitutionAddressId = 4,
            };
            var project = new Project
            {
                ProjectId = 1
            };
            var participant = new Participant
            {
                ParticipantId = participantPerson.ParticipantId,
                ProjectId     = project.ProjectId,
                Project       = project
            };

            participantPerson.Participant = participant;
            project.Participants.Add(participant);

            context.Projects.Add(project);
            context.Participants.Add(participant);
            context.ParticipantPersons.Add(participantPerson);

            var participantPersonResult = ParticipantPersonQueries.CreateGetSimpleParticipantPersonsDTOQuery(context).FirstOrDefault();

            Assert.AreEqual(participantPerson.SevisId, participantPersonResult.SevisId);
            Assert.AreEqual(project.ProjectId, participantPersonResult.ProjectId);
            Assert.AreEqual(participantPerson.HomeInstitutionAddressId, participantPersonResult.HomeInstitutionAddressId);
            Assert.AreEqual(participantPerson.HostInstitutionAddressId, participantPersonResult.HostInstitutionAddressId);

            Assert.AreEqual(0, participantPersonResult.ParticipantTypeId);
            Assert.IsFalse(participantPersonResult.ParticipantStatusId.HasValue);
            Assert.IsNull(participantPersonResult.FieldOfStudy);
            Assert.IsNull(participantPersonResult.ProgramCategory);
            Assert.IsNull(participantPersonResult.Position);
            Assert.IsNull(participantPersonResult.HostInstitution);
            Assert.IsNull(participantPersonResult.HomeInstitution);
        }
 /// <summary>
 /// Returns true if all conditions are met stating sevis validation should run on a participant.
 /// </summary>
 /// <param name="participant">The participant.</param>
 /// <param name="participantPerson">The participant person.</param>
 /// <returns>True, if sevis exchange visitor validation should run; otherwise, false.</returns>
 public bool ShouldRunValidation(Participant participant, ParticipantPerson participantPerson)
 {
     if (participant.ParticipantTypeId != ParticipantType.ForeignTravelingParticipant.Id)
     {
         return(false);
     }
     if (!participant.ParticipantStatusId.HasValue)
     {
         return(false);
     }
     if (!ParticipantStatus.EXCHANGE_VISITOR_VALIDATION_PARTICIPANT_STATUSES.Select(x => x.Id).Contains(participant.ParticipantStatusId.Value))
     {
         return(false);
     }
     if (participantPerson.IsCancelled || participantPerson.IsSentToSevisViaRTI || participantPerson.IsValidatedViaRTI)
     {
         return(false);
     }
     return(true);
 }
Exemplo n.º 12
0
        /// <summary>
        /// Create a participant
        /// </summary>
        /// <param name="person">Person to associate with participant</param>
        /// <param name="participantTypeId">Participant type id</param>
        /// <param name="project">Project to assocate with participant</param>
        /// <returns></returns>
        private Participant CreateParticipant(Person person, int participantTypeId, Project project)
        {
            var participant = new Participant
            {
                PersonId          = person.PersonId,
                ParticipantTypeId = participantTypeId
            };
            var participantPerson = new ParticipantPerson
            {
                Participant = participant
            };

            participant.ParticipantPerson = participantPerson;
            participant.Project           = project;
            person.Participations.Add(participant);
            this.Context.Participants.Add(participant);
            this.Context.ParticipantPersons.Add(participantPerson);
            this.logger.Trace("Creating new participant {0}.", person);
            return(participant);
        }
Exemplo n.º 13
0
 private void CreateParticipantExchangeVisitors(List <Participant> participants)
 {
     foreach (var participant in participants)
     {
         if (participant.ParticipantPerson == null)
         {
             var participantPerson = new ParticipantPerson
             {
                 Participant = participant
             };
             Context.ParticipantPersons.Add(participantPerson);
         }
         var participantExchangeVisitor = new ParticipantExchangeVisitor
         {
             Participant       = participant,
             ParticipantPerson = participant.ParticipantPerson
         };
         Context.ParticipantExchangeVisitors.Add(participantExchangeVisitor);
     }
 }
Exemplo n.º 14
0
        public void TestCreateGetSevisGroupedParticipantsQuery_IsNotQueuedToSubmitOrIsQueuedToValidate()
        {
            var project = new Project
            {
                ProjectId = 1
            };
            var participant = new Participant
            {
                ParticipantId = 10,
                ProjectId     = project.ProjectId,
                Project       = project
            };
            var participantPerson = new ParticipantPerson
            {
                ParticipantId = participant.ParticipantId,
                Participant   = participant,
                SevisId       = "sevis id"
            };

            participant.ParticipantPerson = participantPerson;

            var status = new ParticipantPersonSevisCommStatus
            {
                Id                = 1,
                AddedOn           = DateTimeOffset.Now,
                ParticipantId     = participant.ParticipantId,
                ParticipantPerson = participantPerson,
                SevisCommStatusId = SevisCommStatus.ReadyToSubmit.Id
            };

            participantPerson.ParticipantPersonSevisCommStatuses.Add(status);

            context.Projects.Add(project);
            context.ParticipantPersons.Add(participantPerson);
            context.Participants.Add(participant);
            context.ParticipantPersonSevisCommStatuses.Add(status);

            var results = SevisBatchProcessingQueries.CreateGetSevisGroupedParticipantsQuery(context).ToList();

            Assert.AreEqual(0, results.Count);
        }
Exemplo n.º 15
0
        private void DoUpdate(ParticipantPerson participantPerson, UpdatedParticipantPersonSevis updatedParticipantPersonSevis)
        {
            updatedParticipantPersonSevis.Audit.SetHistory(participantPerson);

            /// typically only one of the below would be changed in the record at a time.  If more than one, this is the order to add them.
            if (!participantPerson.IsSentToSevisViaRTI && updatedParticipantPersonSevis.IsSentToSevisViaRTI)
            {
                // User manual clicked Sent to SEVIS via RTI
                AddSevisCommStatus(SevisCommStatus.SentToDhsViaRti.Id, participantPerson.ParticipantId, updatedParticipantPersonSevis.Audit.User.Id);
            }
            if (!participantPerson.IsDS2019Printed && updatedParticipantPersonSevis.IsDS2019Printed)
            {
                // User printed DS-2019
                AddSevisCommStatus(SevisCommStatus.Ds2019Printed.Id, participantPerson.ParticipantId, updatedParticipantPersonSevis.Audit.User.Id);
            }
            if (!participantPerson.IsDS2019SentToTraveler && updatedParticipantPersonSevis.IsDS2019SentToTraveler)
            {
                // TODO:  Check if this is correct
                AddSevisCommStatus(SevisCommStatus.Ds2019SentToTraveler.Id, participantPerson.ParticipantId, updatedParticipantPersonSevis.Audit.User.Id);
            }
            if (!participantPerson.IsValidatedViaRTI && updatedParticipantPersonSevis.IsValidatedViaRTI)
            {
                // User manually validated
                AddSevisCommStatus(SevisCommStatus.ValidatedViaRti.Id, participantPerson.ParticipantId, updatedParticipantPersonSevis.Audit.User.Id);
            }
            if (!participantPerson.IsCancelled && updatedParticipantPersonSevis.IsCancelled)
            {
                // User manually clicked cancel, add event to ParticipantPersonSevisCommStatus
                AddSevisCommStatus(SevisCommStatus.Cancelled.Id, participantPerson.ParticipantId, updatedParticipantPersonSevis.Audit.User.Id);
            }

            participantPerson.SevisId                = updatedParticipantPersonSevis.SevisId;
            participantPerson.IsSentToSevisViaRTI    = updatedParticipantPersonSevis.IsSentToSevisViaRTI;
            participantPerson.IsValidatedViaRTI      = updatedParticipantPersonSevis.IsValidatedViaRTI;
            participantPerson.IsCancelled            = updatedParticipantPersonSevis.IsCancelled;
            participantPerson.IsDS2019Printed        = updatedParticipantPersonSevis.IsDS2019Printed;
            participantPerson.IsDS2019SentToTraveler = updatedParticipantPersonSevis.IsDS2019SentToTraveler;
            participantPerson.StartDate              = updatedParticipantPersonSevis.StartDate;
            participantPerson.EndDate                = updatedParticipantPersonSevis.EndDate;
        }
        private void DoCreateOrUpdate(
            UpdatedParticipantPerson updatedPerson,
            Participant participant,
            ParticipantPerson participantPerson,
            ParticipantType participantType,
            ParticipantStatus participantStatus,
            Organization host,
            Organization home,
            Address hostAddress,
            Address homeAddress)
        {
            participantPersonValidator.ValidateUpdate(GetUpdatedPersonParticipantValidationEntity(participantType));
            updatedPerson.Audit.SetHistory(participant);
            updatedPerson.Audit.SetHistory(participantPerson);

            participantPerson.HomeInstitutionId        = updatedPerson.HomeInstitutionId;
            participantPerson.HomeInstitutionAddressId = updatedPerson.HomeInstitutionAddressId;

            participantPerson.HostInstitutionId        = updatedPerson.HostInstitutionId;
            participantPerson.HostInstitutionAddressId = updatedPerson.HostInstitutionAddressId;
            participant.ParticipantTypeId   = updatedPerson.ParticipantTypeId;
            participant.ParticipantStatusId = updatedPerson.ParticipantStatusId;
        }
        /// <summary>
        /// Returns the exchange visitor model given the required exchange vistor information.
        /// </summary>
        /// <param name="user">The user requesting the exchange visitor.</param>
        /// <param name="isValidated">True, if the exchange visitor has been validated in sevis.</param>
        /// <param name="person">The exchange visitor person model.</param>
        /// <param name="financialInfo">The financial information.</param>
        /// <param name="participantPerson">The participant person record for the participant.</param>
        /// <param name="occupationCategoryCode">The occupation category code.</param>
        /// <param name="dependents">The dependents for the exchange visitor.</param>
        /// <param name="siteOfActivity">The site of activity, i.e. C Street state dept.</param>
        /// <returns>The exchange visitor.</returns>
        public ExchangeVisitor GetExchangeVisitor(
            bool isValidated,
            Validation.Sevis.Bio.Person person,
            FinancialInfo financialInfo,
            ParticipantPerson participantPerson,
            string occupationCategoryCode,
            IEnumerable <DependentBiographicalDTO> dependents,
            AddressDTO siteOfActivity,
            string sevisOrgId)
        {
            Contract.Requires(person != null, "The person must not be null.");
            Contract.Requires(financialInfo != null, "The financial info must not be null.");
            Contract.Requires(participantPerson != null, "The participant person must not be null.");
            Contract.Requires(siteOfActivity != null, "The site of activity must not be null.");

            var exchangeVisitorDependents = new List <Dependent>();

            if (dependents != null)
            {
                foreach (var dependent in dependents)
                {
                    exchangeVisitorDependents.Add(dependent.GetDependent(siteOfActivity, null));
                }
            }

            return(new ExchangeVisitor(
                       sevisId: participantPerson.SevisId,
                       isValidated: isValidated,
                       sevisOrgId: sevisOrgId,
                       person: person,
                       financialInfo: financialInfo,
                       occupationCategoryCode: occupationCategoryCode,
                       programEndDate: participantPerson.EndDate.HasValue ? participantPerson.EndDate.Value.DateTime : default(DateTime),
                       programStartDate: participantPerson.StartDate.HasValue ? participantPerson.StartDate.Value.DateTime : default(DateTime),
                       dependents: exchangeVisitorDependents,
                       siteOfActivity: siteOfActivity));
        }
        public void TestCreateGetSimpleParticipantPersonsDTOQuery_CheckParticipantType()
        {
            var participantType = new ParticipantType
            {
                ParticipantTypeId = 1,
                Name = "type"
            };

            var participantPerson = new ParticipantPerson
            {
                ParticipantId = 1
            };
            var project = new Project
            {
                ProjectId = 1
            };
            var participant = new Participant
            {
                ParticipantId     = participantPerson.ParticipantId,
                ProjectId         = project.ProjectId,
                Project           = project,
                ParticipantType   = participantType,
                ParticipantTypeId = participantType.ParticipantTypeId
            };

            participantPerson.Participant = participant;
            project.Participants.Add(participant);

            context.Projects.Add(project);
            context.Participants.Add(participant);
            context.ParticipantPersons.Add(participantPerson);
            var participantPersonResult = ParticipantPersonQueries.CreateGetSimpleParticipantPersonsDTOQuery(context).FirstOrDefault();

            Assert.AreEqual(participantType.Name, participantPersonResult.ParticipantType);
            Assert.AreEqual(participantType.ParticipantTypeId, participantPersonResult.ParticipantTypeId);
        }
        public void TestCreateGetSimpleParticipantPersonsDTOQuery_CheckParticipantStatus()
        {
            var participantStatus = new ParticipantStatus
            {
                ParticipantStatusId = 1,
                Status = "status"
            };

            var participantPerson = new ParticipantPerson
            {
                ParticipantId = 1
            };
            var project = new Project
            {
                ProjectId = 1
            };
            var participant = new Participant
            {
                ParticipantId       = participantPerson.ParticipantId,
                ProjectId           = project.ProjectId,
                Project             = project,
                Status              = participantStatus,
                ParticipantStatusId = participantStatus.ParticipantStatusId,
            };

            participantPerson.Participant = participant;
            project.Participants.Add(participant);

            context.Projects.Add(project);
            context.Participants.Add(participant);
            context.ParticipantPersons.Add(participantPerson);
            var participantPersonResult = ParticipantPersonQueries.CreateGetSimpleParticipantPersonsDTOQuery(context).FirstOrDefault();

            Assert.AreEqual(participantStatus.Status, participantPersonResult.ParticipantStatus);
            Assert.AreEqual(participantStatus.ParticipantStatusId, participantPersonResult.ParticipantStatusId);
        }
        public void TestCreateGetSimpleParticipantPersonsDTOQuery_HomeInstitution()
        {
            var country = new Location
            {
                LocationId     = 2,
                LocationTypeId = LocationType.Country.Id,
                LocationName   = "country"
            };

            var city = new Location
            {
                LocationId     = 3,
                LocationTypeId = LocationType.City.Id,
                LocationName   = "city"
            };
            var division = new Location
            {
                LocationId     = 10,
                LocationTypeId = LocationType.Division.Id,
                LocationName   = "state"
            };

            var location = new Location
            {
                LocationId     = 1,
                LocationTypeId = LocationType.Address.Id,
                Street1        = "street1",
                Street2        = "street2",
                Street3        = "street3",
                Country        = country,
                CountryId      = country.LocationId,
                CityId         = city.LocationId,
                City           = city,
                PostalCode     = "12345",
                DivisionId     = division.LocationId,
                Division       = division
            };
            var addressType = new AddressType
            {
                AddressTypeId = AddressType.Home.Id,
                AddressName   = AddressType.Home.Value
            };
            var address = new Address
            {
                AddressId     = 1,
                Location      = location,
                AddressType   = addressType,
                AddressTypeId = addressType.AddressTypeId,
                IsPrimary     = true
            };

            var orgType = new OrganizationType
            {
                OrganizationTypeId   = OrganizationType.ForeignEducationalInstitution.Id,
                OrganizationTypeName = OrganizationType.ForeignEducationalInstitution.Value
            };
            var homeInstitution = new Organization
            {
                OrganizationId     = 1,
                Name               = "homeInstitution",
                OrganizationType   = orgType,
                OrganizationTypeId = orgType.OrganizationTypeId,
            };

            homeInstitution.Addresses.Add(address);

            var participantPerson = new ParticipantPerson
            {
                ParticipantId            = 1,
                HomeInstitution          = homeInstitution,
                HomeInstitutionId        = homeInstitution.OrganizationId,
                HomeInstitutionAddressId = address.AddressId,
            };
            var project = new Project
            {
                ProjectId = 1
            };
            var participant = new Participant
            {
                ParticipantId = participantPerson.ParticipantId,
                ProjectId     = project.ProjectId,
                Project       = project
            };

            participantPerson.Participant = participant;
            project.Participants.Add(participant);

            context.Organizations.Add(homeInstitution);
            context.OrganizationTypes.Add(orgType);
            context.Addresses.Add(address);
            context.AddressTypes.Add(addressType);
            context.Projects.Add(project);
            context.Participants.Add(participant);
            context.ParticipantPersons.Add(participantPerson);

            var participantPersonResult = ParticipantPersonQueries.CreateGetSimpleParticipantPersonsDTOQuery(context).FirstOrDefault();

            Assert.IsNotNull(participantPersonResult.HomeInstitution);
            Assert.AreEqual(homeInstitution.OrganizationId, participantPersonResult.HomeInstitution.OrganizationId);
            Assert.AreEqual(homeInstitution.Name, participantPersonResult.HomeInstitution.Name);
            Assert.AreEqual(address.AddressId, participantPersonResult.HomeInstitutionAddressId);
            var addressResult = participantPersonResult.HomeInstitution.Addresses.FirstOrDefault();

            Assert.AreEqual(location.Street1, addressResult.Street1);
            Assert.AreEqual(location.Street2, addressResult.Street2);
            Assert.AreEqual(location.Street3, addressResult.Street3);
            Assert.AreEqual(country.LocationName, addressResult.Country);
            Assert.AreEqual(country.LocationId, addressResult.CountryId);
            Assert.AreEqual(location.City.LocationName, addressResult.City);
            Assert.AreEqual(location.PostalCode, addressResult.PostalCode);
            Assert.AreEqual(location.LocationId, addressResult.LocationId);
            Assert.AreEqual(address.AddressId, addressResult.AddressId);
            Assert.AreEqual(addressType.AddressTypeId, addressResult.AddressTypeId);
            Assert.AreEqual(addressType.AddressName, addressResult.AddressType);
            Assert.AreEqual(address.IsPrimary, addressResult.IsPrimary);
            Assert.AreEqual(division.LocationId, addressResult.DivisionId);
            Assert.AreEqual(division.LocationName, addressResult.Division);
        }
Exemplo n.º 21
0
 /// <summary>
 /// Creates a new instance.
 /// </summary>
 /// <param name="participantPerson">The participant person.</param>
 /// <param name="updatedParticipantPersonSevis">The participant person sevis.</param>
 public UpdatedParticipantPersonSevisValidationEntity(ParticipantPerson participantPerson, UpdatedParticipantPersonSevis updatedParticipantPersonSevis)
 {
     this.participantPerson             = participantPerson;
     this.updatedParticipantPersonSevis = updatedParticipantPersonSevis;
 }
Exemplo n.º 22
0
 private UpdatedParticipantPersonSevisValidationEntity GetUpdatedParticipantPersonSevisValidationEntity(ParticipantPerson participantPerson, UpdatedParticipantPersonSevis participantPersonSevis)
 {
     return(new UpdatedParticipantPersonSevisValidationEntity(participantPerson, participantPersonSevis));
 }
        public void TestCreateGetParticipantPersonsSevisDTOQuery_NoStatusesHaveBatchId()
        {
            var person = new Person
            {
                PersonId = 1,
                FullName = "full name"
            };
            var status = new ParticipantStatus
            {
                ParticipantStatusId = 1,
                Status = "status",
            };
            var participantType = new ParticipantType
            {
                IsPerson          = true,
                Name              = "part type",
                ParticipantTypeId = 90
            };
            var participant = new Participant
            {
                ParticipantId       = 1,
                Status              = status,
                ParticipantStatusId = status.ParticipantStatusId,
                ProjectId           = 250,
                ParticipantTypeId   = participantType.ParticipantTypeId,
                ParticipantType     = participantType,
                PersonId            = person.PersonId,
                Person              = person
            };

            var participantPerson = new ParticipantPerson
            {
                ParticipantId          = participant.ParticipantId,
                Participant            = participant,
                EndDate                = DateTimeOffset.UtcNow.AddDays(10.0),
                IsCancelled            = true,
                IsDS2019Printed        = true,
                IsDS2019SentToTraveler = true,
                IsSentToSevisViaRTI    = true,
                IsValidatedViaRTI      = true,
                SevisBatchResult       = "sevis batch result",
                SevisId                = "sevis id",
                SevisValidationResult  = "sevis validation result",
                StartDate              = DateTimeOffset.UtcNow.AddDays(-10.0)
            };

            participant.ParticipantPerson = participantPerson;

            var readyToSubmitStatus = new SevisCommStatus
            {
                SevisCommStatusId   = SevisCommStatus.ReadyToSubmit.Id,
                SevisCommStatusName = SevisCommStatus.ReadyToSubmit.Value
            };
            var pendingSendToSevisStatus = new SevisCommStatus
            {
                SevisCommStatusId   = SevisCommStatus.PendingSevisSend.Id,
                SevisCommStatusName = SevisCommStatus.PendingSevisSend.Value
            };
            var yesterdayStatus = new ParticipantPersonSevisCommStatus
            {
                AddedOn           = DateTimeOffset.UtcNow.AddDays(-1.0),
                Id                = 500,
                ParticipantId     = participant.ParticipantId,
                ParticipantPerson = participantPerson,
                SevisCommStatus   = readyToSubmitStatus,
                SevisCommStatusId = readyToSubmitStatus.SevisCommStatusId,
            };
            var todayStatus = new ParticipantPersonSevisCommStatus
            {
                AddedOn           = DateTimeOffset.UtcNow,
                Id                = 501,
                ParticipantId     = participant.ParticipantId,
                ParticipantPerson = participantPerson,
                SevisCommStatus   = pendingSendToSevisStatus,
                SevisCommStatusId = pendingSendToSevisStatus.SevisCommStatusId,
            };

            participantPerson.ParticipantPersonSevisCommStatuses.Add(todayStatus);
            participantPerson.ParticipantPersonSevisCommStatuses.Add(yesterdayStatus);

            context.SevisCommStatuses.Add(readyToSubmitStatus);
            context.SevisCommStatuses.Add(pendingSendToSevisStatus);
            context.ParticipantPersonSevisCommStatuses.Add(todayStatus);
            context.ParticipantPersonSevisCommStatuses.Add(yesterdayStatus);
            context.ParticipantTypes.Add(participantType);
            context.ParticipantStatuses.Add(status);
            context.Participants.Add(participant);
            context.ParticipantPersons.Add(participantPerson);
            context.People.Add(person);

            var results = ParticipantPersonsSevisQueries.CreateGetParticipantPersonsSevisDTOQuery(context).ToList();

            Assert.AreEqual(1, results.Count());
            var firstResult = results.First();

            Assert.IsNull(firstResult.LastBatchDate);
        }
        private ParticipantPersonSevisCommStatus HandleValidationResult(ExchangeVisitor exchangeVisitor, ParticipantPerson person, ValidationResult result)
        {
            //remember this method should be as performant as possible since lots of different entity edits can cause this method to run
            person.SevisValidationResult = GetSevisValidationResultAsJson(result);
            var latestCommStatus = CreateGetLatestParticipantPersonSevisCommStatusQuery(person.ParticipantId).FirstOrDefault();

            if (!result.IsValid)
            {
                if (!String.IsNullOrWhiteSpace(person.SevisId))
                {
                    var isParticipantReadyToValidate = this.participantPersonSevisService.IsParticipantReadyToValidate(person.ParticipantId);
                    if (isParticipantReadyToValidate)
                    {
                        return(AddOrUpdateParticipantPersonSevisCommStatus(latestCommStatus, person.ParticipantId, SevisCommStatus.NeedsValidationInfo.Id));
                    }

                    var hasParticipantNeededValidationInfo = CreateGetParticipantPersonSevisCommStatusBySevisCommStatusIdQuery(person.ParticipantId, SevisCommStatus.NeedsValidationInfo.Id).Count() > 0;
                    if (!exchangeVisitor.IsValidated && hasParticipantNeededValidationInfo)
                    {
                        return(AddOrUpdateParticipantPersonSevisCommStatus(latestCommStatus, person.ParticipantId, SevisCommStatus.NeedsValidationInfo.Id));
                    }

                    return(AddOrUpdateParticipantPersonSevisCommStatus(latestCommStatus, person.ParticipantId, SevisCommStatus.InformationRequired.Id));
                }
                else
                {
                    return(AddOrUpdateParticipantPersonSevisCommStatus(latestCommStatus, person.ParticipantId, SevisCommStatus.InformationRequired.Id));
                }
            }
            else
            {
                var hasParticipantNeededValidationInfo = CreateGetParticipantPersonSevisCommStatusBySevisCommStatusIdQuery(person.ParticipantId, SevisCommStatus.NeedsValidationInfo.Id).Count() > 0;
                var isParticipantReadyToValidate       = this.participantPersonSevisService.IsParticipantReadyToValidate(person.ParticipantId);
                if ((hasParticipantNeededValidationInfo && !exchangeVisitor.IsValidated) || isParticipantReadyToValidate)
                {
                    return(AddParticipantPersonSevisCommStatus(person.ParticipantId, SevisCommStatus.ReadyToValidate.Id));
                }
                else
                {
                    return(AddParticipantPersonSevisCommStatus(person.ParticipantId, SevisCommStatus.ReadyToSubmit.Id));
                }
            }
        }
Exemplo n.º 25
0
        public async Task TestProcessTransactionLog_TransactionLogHasNewParticipantAndNewDependent()
        {
            var               expectedParticipantSevisId = "N0000158857";
            var               expectedDependentSevisId   = "N0000158274";
            var               transactionXml             = ECA.Business.Test.Properties.Resources.TransactionLogWithNewParticipantAndNewDependent;
            var               batchXml          = ECA.Business.Test.Properties.Resources.NewParticipantWithNewDependentBatchXml;
            var               user              = new User(1);
            var               yesterday         = DateTimeOffset.UtcNow.AddDays(-1.0);
            var               otherUser         = new User(user.Id + 1);
            var               batchId           = "----kynEn47azQ";
            Participant       participant       = null;
            ParticipantPerson participantPerson = null;
            PersonDependent   personDependent   = null;

            Data.Person            person  = null;
            SevisBatchProcessing   batch   = null;
            ExchangeVisitorHistory history = null;
            var personId      = 63280;
            var participantId = 59079;

            context.SetupActions.Add(() =>
            {
                batch = new SevisBatchProcessing
                {
                    BatchId    = batchId,
                    Id         = 1,
                    SendString = batchXml
                };
                participant = new Participant
                {
                    ParticipantId = participantId
                };
                participantPerson = new ParticipantPerson
                {
                    ParticipantId    = participant.ParticipantId,
                    Participant      = participant,
                    SevisBatchResult = "sevis batch result",
                };
                participantPerson.History.CreatedBy = otherUser.Id;
                participantPerson.History.CreatedOn = yesterday;
                participantPerson.History.RevisedBy = otherUser.Id;
                participantPerson.History.RevisedOn = yesterday;

                participant.ParticipantPerson = participantPerson;
                person = new Data.Person
                {
                    PersonId = personId
                };
                participant.Person   = person;
                participant.PersonId = person.PersonId;

                personDependent = new PersonDependent
                {
                    DependentId = 6,
                    Person      = person,
                    PersonId    = person.PersonId
                };
                person.Family.Add(personDependent);
                history = new ExchangeVisitorHistory
                {
                    ParticipantId = participantId
                };
                context.ExchangeVisitorHistories.Add(history);
                context.PersonDependents.Add(personDependent);
                context.Participants.Add(participant);
                context.ParticipantPersons.Add(participantPerson);
                context.People.Add(person);
                context.SevisBatchProcessings.Add(batch);
            });

            Action tester = () =>
            {
                Assert.AreEqual(expectedParticipantSevisId, participantPerson.SevisId);
                Assert.AreEqual(expectedDependentSevisId, personDependent.SevisId);
            };

            context.Revert();
            service.ProcessTransactionLog(user, batchId, transactionXml, fileProvider.Object);
            tester();

            context.Revert();
            await service.ProcessTransactionLogAsync(user, batchId, transactionXml, fileProvider.Object);

            tester();
        }
Exemplo n.º 26
0
        public async Task TestUpdate_SocialMedia_SevisNotLocked()
        {
            var personId      = 1;
            var participantId = 1;
            var creator       = 1;
            var updatorId     = 2;
            var updator       = new User(updatorId);
            var facebookType  = new SocialMediaType
            {
                SocialMediaTypeId   = SocialMediaType.Facebook.Id,
                SocialMediaTypeName = SocialMediaType.Facebook.Value
            };
            var twitter = new SocialMediaType
            {
                SocialMediaTypeId   = SocialMediaType.Twitter.Id,
                SocialMediaTypeName = SocialMediaType.Twitter.Value
            };

            var    oldSocialMediaTypeId = facebookType.SocialMediaTypeId;
            var    oldValue             = "oldValue";
            var    yesterday            = DateTimeOffset.Now.AddDays(-1.0);
            Person person = new Person
            {
                PersonId = personId
            };
            var socialMedia = new SocialMedia
            {
                SocialMediaId = 1,
                Person        = person,
                PersonId      = person.PersonId
            };
            var participant = new Participant
            {
                ParticipantId       = participantId,
                PersonId            = person.PersonId,
                ParticipantStatusId = ParticipantStatus.Active.Id
            };
            List <Participant> participants = new List <Participant>();

            participants.Add(participant);
            person.Participations = participants;
            var participantPerson = new ParticipantPerson
            {
                Participant   = participant,
                ParticipantId = participant.ParticipantId,
            };

            participant.ParticipantPerson = participantPerson;

            var queuedToSubmitStatus = new SevisCommStatus
            {
                SevisCommStatusId   = SevisCommStatus.InformationRequired.Id,
                SevisCommStatusName = SevisCommStatus.InformationRequired.Value
            };
            var commStatus = new ParticipantPersonSevisCommStatus
            {
                AddedOn           = DateTimeOffset.UtcNow,
                BatchId           = "batch id",
                Id                = 501,
                ParticipantId     = participant.ParticipantId,
                ParticipantPerson = participantPerson,
                SevisCommStatus   = queuedToSubmitStatus,
                SevisCommStatusId = queuedToSubmitStatus.SevisCommStatusId,
            };

            participantPerson.ParticipantPersonSevisCommStatuses.Add(commStatus);
            person.SocialMedias.Add(socialMedia);

            context.SetupActions.Add(() =>
            {
                context.SocialMedias.Add(socialMedia);
                context.SocialMediaTypes.Add(facebookType);
                context.SocialMediaTypes.Add(twitter);
                context.Participants.Add(participant);
                context.ParticipantPersons.Add(participantPerson);
                context.ParticipantPersonSevisCommStatuses.Add(commStatus);
                socialMedia.History.CreatedBy = creator;
                socialMedia.History.CreatedOn = yesterday;
                socialMedia.History.RevisedBy = creator;
                socialMedia.History.RevisedOn = yesterday;
                socialMedia.SocialMediaTypeId = facebookType.SocialMediaTypeId;
                socialMedia.SocialMediaType   = facebookType;
                socialMedia.SocialMediaValue  = oldValue;
            });
            context.Revert();

            var updatedSocialMedia = new UpdatedSocialMediaPresence(updator, socialMedia.SocialMediaId, "newValue", twitter.SocialMediaTypeId);

            var message = String.Format("An update was attempted on participant with id [{0}] but should have failed validation.",
                                        participant.ParticipantId);

            Action      a = () => service.Update(updatedSocialMedia);
            Func <Task> f = () => service.UpdateAsync(updatedSocialMedia);

            a.ShouldNotThrow <EcaBusinessException>();
            f.ShouldNotThrow <EcaBusinessException>();
        }
 private void HandleNonValidatedParticipant(ParticipantPerson person)
 {
     person.SevisValidationResult = null;
 }
        public async Task TestUpdate_PersonEmail_SevisNotLocked()
        {
            var    personId      = 1;
            var    participantId = 1;
            Person person        = new Person
            {
                PersonId = personId
            };
            var participant = new Participant
            {
                ParticipantId       = participantId,
                PersonId            = person.PersonId,
                ParticipantStatusId = ParticipantStatus.Active.Id
            };
            List <Participant> participants = new List <Participant>();

            participants.Add(participant);
            person.Participations = participants;
            var participantPerson = new ParticipantPerson
            {
                Participant   = participant,
                ParticipantId = participant.ParticipantId,
            };

            participant.ParticipantPerson = participantPerson;

            var queuedToSubmitStatus = new SevisCommStatus
            {
                SevisCommStatusId   = SevisCommStatus.InformationRequired.Id,
                SevisCommStatusName = SevisCommStatus.InformationRequired.Value
            };
            var commStatus = new ParticipantPersonSevisCommStatus
            {
                AddedOn           = DateTimeOffset.UtcNow,
                BatchId           = "batch id",
                Id                = 501,
                ParticipantId     = participant.ParticipantId,
                ParticipantPerson = participantPerson,
                SevisCommStatus   = queuedToSubmitStatus,
                SevisCommStatusId = queuedToSubmitStatus.SevisCommStatusId,
            };

            participantPerson.ParticipantPersonSevisCommStatuses.Add(commStatus);

            EmailAddressType emailAddressType = new EmailAddressType
            {
                EmailAddressTypeId   = EmailAddressType.Home.Id,
                EmailAddressTypeName = EmailAddressType.Home.Value
            };
            var          creatorId            = 1;
            var          updatorId            = 2;
            var          yesterday            = DateTimeOffset.UtcNow.AddDays(-1.0);
            var          emailAddressId       = 1;
            EmailAddress emailAddressToUpdate = null;

            context.SetupActions.Add(() =>
            {
                emailAddressToUpdate = new EmailAddress
                {
                    EmailAddressId = emailAddressId,
                    Person         = person,
                    PersonId       = person.PersonId
                };
                emailAddressToUpdate.History.CreatedBy = creatorId;
                emailAddressToUpdate.History.RevisedBy = creatorId;
                emailAddressToUpdate.History.CreatedOn = yesterday;
                emailAddressToUpdate.History.RevisedOn = yesterday;

                person.EmailAddresses.Add(emailAddressToUpdate);
                context.EmailAddressTypes.Add(emailAddressType);
                context.People.Add(person);
                context.EmailAddresses.Add(emailAddressToUpdate);
                context.Participants.Add(participant);
                context.ParticipantPersons.Add(participantPerson);
                context.ParticipantPersonSevisCommStatuses.Add(commStatus);
            });
            context.Revert();
            var updatedEmailModel = new UpdatedEmailAddress(new User(updatorId), emailAddressId, "*****@*****.**", emailAddressType.EmailAddressTypeId, true);

            var message = String.Format("An update was attempted on participant with id [{0}] but should have failed validation.",
                                        participant.ParticipantId);

            Action      a = () => service.Update(updatedEmailModel);
            Func <Task> f = () => service.UpdateAsync(updatedEmailModel);

            a.ShouldNotThrow <EcaBusinessException>();
            f.ShouldNotThrow <EcaBusinessException>();
        }