/// <summary> /// Adds the specified role to this person. /// </summary> /// <param name="role">The role.</param> /// <returns> /// True if successful, false if not /// </returns> public bool AddRole(PersonRoles role) { int sizeBefore = this.Roles.Count; this.Roles.Add(role); return(this.Roles.Count == (sizeBefore + 1)); }
/// <summary> /// Removes the role. /// </summary> /// <param name="role">The role.</param> /// <returns> /// True if successful, false if not /// </returns> public bool RemoveRole(PersonRoles role) { int sizeBefore = this.Roles.Count; this.Roles.Remove(role); return(this.Roles.Count == (sizeBefore - 1)); }
/// <summary> /// This method returns a string containing all the roles of a community member. /// </summary> /// <param name="personId">The Id of the person.</param> /// <returns>A string with all the person's roles.</returns> public string BuildRolesString(int personId) { List <PersonRole> roles = PersonRoles.FindAll(pr => pr.PersonId == personId); List <string> roleNames = new List <string>(); foreach (var pr in roles) { roleNames.Add(pr.RoleName); } return(string.Join(", ", roleNames)); }
public IQueryable <ComboBoxResult> GetCustomPerson(int Id, string term) { int DocTypeId = Id; int SiteId = (int)System.Web.HttpContext.Current.Session["SiteId"]; int DivisionId = (int)System.Web.HttpContext.Current.Session["DivisionId"]; var settings = new ProdOrderSettingsService(_unitOfWork).GetProdOrderSettingsForDocument(DocTypeId, DivisionId, SiteId); string[] PersonRoles = null; if (!string.IsNullOrEmpty(settings.filterPersonRoles)) { PersonRoles = settings.filterPersonRoles.Split(",".ToCharArray()); } else { PersonRoles = new string[] { "NA" }; } string DivIdStr = "|" + DivisionId.ToString() + "|"; string SiteIdStr = "|" + SiteId.ToString() + "|"; int ProcessId = new ProcessService(_unitOfWork).Find(ProcessConstants.Sales).ProcessId; var list = (from p in db.Persons join bus in db.BusinessEntity on p.PersonID equals bus.PersonID into BusinessEntityTable from BusinessEntityTab in BusinessEntityTable.DefaultIfEmpty() join pp in db.PersonProcess on p.PersonID equals pp.PersonId into PersonProcessTable from PersonProcessTab in PersonProcessTable.DefaultIfEmpty() join pr in db.PersonRole on p.PersonID equals pr.PersonId into PersonRoleTable from PersonRoleTab in PersonRoleTable.DefaultIfEmpty() where PersonProcessTab.ProcessId == ProcessId && (string.IsNullOrEmpty(term) ? 1 == 1 : (p.Name.ToLower().Contains(term.ToLower()) || p.Code.ToLower().Contains(term.ToLower()))) && (string.IsNullOrEmpty(settings.filterPersonRoles) ? 1 == 1 : PersonRoles.Contains(PersonRoleTab.RoleDocTypeId.ToString())) && BusinessEntityTab.DivisionIds.IndexOf(DivIdStr) != -1 && BusinessEntityTab.SiteIds.IndexOf(SiteIdStr) != -1 && (p.IsActive == null ? 1 == 1 : p.IsActive == true) group new { p } by new { p.PersonID } into Result orderby Result.Max(m => m.p.Name) select new ComboBoxResult { id = Result.Key.PersonID.ToString(), text = Result.Max(m => m.p.Name + ", " + m.p.Suffix + " [" + m.p.Code + "]"), } ); return(list); }
/// <summary> /// Initializes a new instance of the <see cref="RegisterForm" /> class. /// Shows username and password fields if the form is being opened to register the initial admin account. /// </summary> /// <param name="role">The role.</param> /// <exception cref="ArgumentOutOfRangeException">This form only supports registering administrators and patients</exception> public RegisterForm(PersonRoles roleRegisteringFor = PersonRoles.Patient) { InitializeComponent(); this.labelErrorMessages.Hide(); this.errorMessages = new List <string>(); this.roleRegisteringFor = roleRegisteringFor; LoginForm?.Hide(); this.formType = FormType.Register; if (this.roleRegisteringFor == PersonRoles.Patient) { this.textBoxUsername.Hide(); this.textBoxPassword.Hide(); this.usernameLabel.Hide(); this.passwordLabel.Hide(); } }
/// <summary> /// Initializes a new instance of the <see cref="RegisterForm"/> class. /// </summary> /// <param name="person">The person.</param> public RegisterForm(Person person) { InitializeComponent(); this.labelErrorMessages.Hide(); this.errorMessages = new List <string>(); this.roleRegisteringFor = PersonRoles.Patient; LoginForm?.Hide(); this.formType = FormType.Update; this.textBoxUsername.Hide(); this.textBoxPassword.Hide(); this.usernameLabel.Hide(); this.passwordLabel.Hide(); this.btnRegister.Text = "UPDATE!"; this.person = person; this.populateFields(person); }
/// <summary> /// Dependent type names of this entity /// </summary> public void DeleteChildren(DatabaseEntities dbContext) { foreach (var x in AgreementPeople.ToList()) { x.DeleteFull(dbContext); } foreach (var x in AuditLogs.ToList()) { x.DeleteFull(dbContext); } foreach (var x in FileResourcesWhereYouAreTheCreatePerson.ToList()) { x.DeleteFull(dbContext); } foreach (var x in GisUploadAttemptsWhereYouAreTheGisUploadAttemptCreatePerson.ToList()) { x.DeleteFull(dbContext); } foreach (var x in GrantAllocationsWhereYouAreTheGrantManager.ToList()) { x.DeleteFull(dbContext); } foreach (var x in GrantAllocationAwardPersonnelAndBenefitsLineItems.ToList()) { x.DeleteFull(dbContext); } foreach (var x in GrantAllocationAwardTravelLineItems.ToList()) { x.DeleteFull(dbContext); } foreach (var x in GrantAllocationChangeLogsWhereYouAreTheChangePerson.ToList()) { x.DeleteFull(dbContext); } foreach (var x in GrantAllocationNotesWhereYouAreTheCreatedByPerson.ToList()) { x.DeleteFull(dbContext); } foreach (var x in GrantAllocationNotesWhereYouAreTheLastUpdatedByPerson.ToList()) { x.DeleteFull(dbContext); } foreach (var x in GrantAllocationNoteInternalsWhereYouAreTheCreatedByPerson.ToList()) { x.DeleteFull(dbContext); } foreach (var x in GrantAllocationNoteInternalsWhereYouAreTheLastUpdatedByPerson.ToList()) { x.DeleteFull(dbContext); } foreach (var x in GrantAllocationProgramManagers.ToList()) { x.DeleteFull(dbContext); } foreach (var x in GrantModificationNoteInternalsWhereYouAreTheCreatedByPerson.ToList()) { x.DeleteFull(dbContext); } foreach (var x in GrantModificationNoteInternalsWhereYouAreTheLastUpdatedByPerson.ToList()) { x.DeleteFull(dbContext); } foreach (var x in GrantNotesWhereYouAreTheCreatedByPerson.ToList()) { x.DeleteFull(dbContext); } foreach (var x in GrantNotesWhereYouAreTheLastUpdatedByPerson.ToList()) { x.DeleteFull(dbContext); } foreach (var x in GrantNoteInternalsWhereYouAreTheCreatedByPerson.ToList()) { x.DeleteFull(dbContext); } foreach (var x in GrantNoteInternalsWhereYouAreTheLastUpdatedByPerson.ToList()) { x.DeleteFull(dbContext); } foreach (var x in InteractionEventsWhereYouAreTheStaffPerson.ToList()) { x.DeleteFull(dbContext); } foreach (var x in InteractionEventContacts.ToList()) { x.DeleteFull(dbContext); } foreach (var x in InvoicesWhereYouAreThePreparedByPerson.ToList()) { x.DeleteFull(dbContext); } foreach (var x in Notifications.ToList()) { x.DeleteFull(dbContext); } foreach (var x in OrganizationsWhereYouAreThePrimaryContactPerson.ToList()) { x.DeleteFull(dbContext); } foreach (var x in PerformanceMeasureNotesWhereYouAreTheCreatePerson.ToList()) { x.DeleteFull(dbContext); } foreach (var x in PerformanceMeasureNotesWhereYouAreTheUpdatePerson.ToList()) { x.DeleteFull(dbContext); } foreach (var x in PeopleWhereYouAreTheAddedByPerson.ToList()) { x.DeleteFull(dbContext); } foreach (var x in PersonAllowedAuthenticators.ToList()) { x.DeleteFull(dbContext); } foreach (var x in PersonRoles.ToList()) { x.DeleteFull(dbContext); } foreach (var x in PersonStewardOrganizations.ToList()) { x.DeleteFull(dbContext); } foreach (var x in PersonStewardRegions.ToList()) { x.DeleteFull(dbContext); } foreach (var x in PersonStewardTaxonomyBranches.ToList()) { x.DeleteFull(dbContext); } foreach (var x in ProgramsWhereYouAreTheProgramCreatePerson.ToList()) { x.DeleteFull(dbContext); } foreach (var x in ProgramsWhereYouAreTheProgramLastUpdatedByPerson.ToList()) { x.DeleteFull(dbContext); } foreach (var x in ProgramsWhereYouAreTheProgramPrimaryContactPerson.ToList()) { x.DeleteFull(dbContext); } foreach (var x in ProgramPeople.ToList()) { x.DeleteFull(dbContext); } foreach (var x in ProjectsWhereYouAreTheProposingPerson.ToList()) { x.DeleteFull(dbContext); } foreach (var x in ProjectsWhereYouAreTheReviewedByPerson.ToList()) { x.DeleteFull(dbContext); } foreach (var x in ProjectInternalNotesWhereYouAreTheCreatePerson.ToList()) { x.DeleteFull(dbContext); } foreach (var x in ProjectInternalNotesWhereYouAreTheUpdatePerson.ToList()) { x.DeleteFull(dbContext); } foreach (var x in ProjectLocationStagings.ToList()) { x.DeleteFull(dbContext); } foreach (var x in ProjectLocationStagingUpdates.ToList()) { x.DeleteFull(dbContext); } foreach (var x in ProjectNotesWhereYouAreTheCreatePerson.ToList()) { x.DeleteFull(dbContext); } foreach (var x in ProjectNotesWhereYouAreTheUpdatePerson.ToList()) { x.DeleteFull(dbContext); } foreach (var x in ProjectNoteUpdatesWhereYouAreTheCreatePerson.ToList()) { x.DeleteFull(dbContext); } foreach (var x in ProjectNoteUpdatesWhereYouAreTheUpdatePerson.ToList()) { x.DeleteFull(dbContext); } foreach (var x in ProjectPeople.ToList()) { x.DeleteFull(dbContext); } foreach (var x in ProjectPersonUpdates.ToList()) { x.DeleteFull(dbContext); } foreach (var x in ProjectUpdateBatchesWhereYouAreTheLastUpdatePerson.ToList()) { x.DeleteFull(dbContext); } foreach (var x in ProjectUpdateHistoriesWhereYouAreTheUpdatePerson.ToList()) { x.DeleteFull(dbContext); } foreach (var x in SupportRequestLogsWhereYouAreTheRequestPerson.ToList()) { x.DeleteFull(dbContext); } foreach (var x in SystemAttributesWhereYouAreThePrimaryContactPerson.ToList()) { x.DeleteFull(dbContext); } foreach (var x in TabularDataImportsWhereYouAreTheLastProcessedPerson.ToList()) { x.DeleteFull(dbContext); } foreach (var x in TabularDataImportsWhereYouAreTheUploadPerson.ToList()) { x.DeleteFull(dbContext); } }
/// <summary> /// Active Dependent type names of this object /// </summary> public List <string> DependentObjectNames() { var dependentObjects = new List <string>(); if (AgreementPeople.Any()) { dependentObjects.Add(typeof(AgreementPerson).Name); } if (AuditLogs.Any()) { dependentObjects.Add(typeof(AuditLog).Name); } if (FileResourcesWhereYouAreTheCreatePerson.Any()) { dependentObjects.Add(typeof(FileResource).Name); } if (GisUploadAttemptsWhereYouAreTheGisUploadAttemptCreatePerson.Any()) { dependentObjects.Add(typeof(GisUploadAttempt).Name); } if (GrantAllocationsWhereYouAreTheGrantManager.Any()) { dependentObjects.Add(typeof(GrantAllocation).Name); } if (GrantAllocationAwardPersonnelAndBenefitsLineItems.Any()) { dependentObjects.Add(typeof(GrantAllocationAwardPersonnelAndBenefitsLineItem).Name); } if (GrantAllocationAwardTravelLineItems.Any()) { dependentObjects.Add(typeof(GrantAllocationAwardTravelLineItem).Name); } if (GrantAllocationChangeLogsWhereYouAreTheChangePerson.Any()) { dependentObjects.Add(typeof(GrantAllocationChangeLog).Name); } if (GrantAllocationNotesWhereYouAreTheCreatedByPerson.Any()) { dependentObjects.Add(typeof(GrantAllocationNote).Name); } if (GrantAllocationNotesWhereYouAreTheLastUpdatedByPerson.Any()) { dependentObjects.Add(typeof(GrantAllocationNote).Name); } if (GrantAllocationNoteInternalsWhereYouAreTheCreatedByPerson.Any()) { dependentObjects.Add(typeof(GrantAllocationNoteInternal).Name); } if (GrantAllocationNoteInternalsWhereYouAreTheLastUpdatedByPerson.Any()) { dependentObjects.Add(typeof(GrantAllocationNoteInternal).Name); } if (GrantAllocationProgramManagers.Any()) { dependentObjects.Add(typeof(GrantAllocationProgramManager).Name); } if (GrantModificationNoteInternalsWhereYouAreTheCreatedByPerson.Any()) { dependentObjects.Add(typeof(GrantModificationNoteInternal).Name); } if (GrantModificationNoteInternalsWhereYouAreTheLastUpdatedByPerson.Any()) { dependentObjects.Add(typeof(GrantModificationNoteInternal).Name); } if (GrantNotesWhereYouAreTheCreatedByPerson.Any()) { dependentObjects.Add(typeof(GrantNote).Name); } if (GrantNotesWhereYouAreTheLastUpdatedByPerson.Any()) { dependentObjects.Add(typeof(GrantNote).Name); } if (GrantNoteInternalsWhereYouAreTheCreatedByPerson.Any()) { dependentObjects.Add(typeof(GrantNoteInternal).Name); } if (GrantNoteInternalsWhereYouAreTheLastUpdatedByPerson.Any()) { dependentObjects.Add(typeof(GrantNoteInternal).Name); } if (InteractionEventsWhereYouAreTheStaffPerson.Any()) { dependentObjects.Add(typeof(InteractionEvent).Name); } if (InteractionEventContacts.Any()) { dependentObjects.Add(typeof(InteractionEventContact).Name); } if (InvoicesWhereYouAreThePreparedByPerson.Any()) { dependentObjects.Add(typeof(Invoice).Name); } if (Notifications.Any()) { dependentObjects.Add(typeof(Notification).Name); } if (OrganizationsWhereYouAreThePrimaryContactPerson.Any()) { dependentObjects.Add(typeof(Organization).Name); } if (PerformanceMeasureNotesWhereYouAreTheCreatePerson.Any()) { dependentObjects.Add(typeof(PerformanceMeasureNote).Name); } if (PerformanceMeasureNotesWhereYouAreTheUpdatePerson.Any()) { dependentObjects.Add(typeof(PerformanceMeasureNote).Name); } if (PeopleWhereYouAreTheAddedByPerson.Any()) { dependentObjects.Add(typeof(Person).Name); } if (PersonAllowedAuthenticators.Any()) { dependentObjects.Add(typeof(PersonAllowedAuthenticator).Name); } if (PersonRoles.Any()) { dependentObjects.Add(typeof(PersonRole).Name); } if (PersonStewardOrganizations.Any()) { dependentObjects.Add(typeof(PersonStewardOrganization).Name); } if (PersonStewardRegions.Any()) { dependentObjects.Add(typeof(PersonStewardRegion).Name); } if (PersonStewardTaxonomyBranches.Any()) { dependentObjects.Add(typeof(PersonStewardTaxonomyBranch).Name); } if (ProgramsWhereYouAreTheProgramCreatePerson.Any()) { dependentObjects.Add(typeof(Program).Name); } if (ProgramsWhereYouAreTheProgramLastUpdatedByPerson.Any()) { dependentObjects.Add(typeof(Program).Name); } if (ProgramsWhereYouAreTheProgramPrimaryContactPerson.Any()) { dependentObjects.Add(typeof(Program).Name); } if (ProgramPeople.Any()) { dependentObjects.Add(typeof(ProgramPerson).Name); } if (ProjectsWhereYouAreTheProposingPerson.Any()) { dependentObjects.Add(typeof(Project).Name); } if (ProjectsWhereYouAreTheReviewedByPerson.Any()) { dependentObjects.Add(typeof(Project).Name); } if (ProjectInternalNotesWhereYouAreTheCreatePerson.Any()) { dependentObjects.Add(typeof(ProjectInternalNote).Name); } if (ProjectInternalNotesWhereYouAreTheUpdatePerson.Any()) { dependentObjects.Add(typeof(ProjectInternalNote).Name); } if (ProjectLocationStagings.Any()) { dependentObjects.Add(typeof(ProjectLocationStaging).Name); } if (ProjectLocationStagingUpdates.Any()) { dependentObjects.Add(typeof(ProjectLocationStagingUpdate).Name); } if (ProjectNotesWhereYouAreTheCreatePerson.Any()) { dependentObjects.Add(typeof(ProjectNote).Name); } if (ProjectNotesWhereYouAreTheUpdatePerson.Any()) { dependentObjects.Add(typeof(ProjectNote).Name); } if (ProjectNoteUpdatesWhereYouAreTheCreatePerson.Any()) { dependentObjects.Add(typeof(ProjectNoteUpdate).Name); } if (ProjectNoteUpdatesWhereYouAreTheUpdatePerson.Any()) { dependentObjects.Add(typeof(ProjectNoteUpdate).Name); } if (ProjectPeople.Any()) { dependentObjects.Add(typeof(ProjectPerson).Name); } if (ProjectPersonUpdates.Any()) { dependentObjects.Add(typeof(ProjectPersonUpdate).Name); } if (ProjectUpdateBatchesWhereYouAreTheLastUpdatePerson.Any()) { dependentObjects.Add(typeof(ProjectUpdateBatch).Name); } if (ProjectUpdateHistoriesWhereYouAreTheUpdatePerson.Any()) { dependentObjects.Add(typeof(ProjectUpdateHistory).Name); } if (SupportRequestLogsWhereYouAreTheRequestPerson.Any()) { dependentObjects.Add(typeof(SupportRequestLog).Name); } if (SystemAttributesWhereYouAreThePrimaryContactPerson.Any()) { dependentObjects.Add(typeof(SystemAttribute).Name); } if (TabularDataImportsWhereYouAreTheLastProcessedPerson.Any()) { dependentObjects.Add(typeof(TabularDataImport).Name); } if (TabularDataImportsWhereYouAreTheUploadPerson.Any()) { dependentObjects.Add(typeof(TabularDataImport).Name); } return(dependentObjects.Distinct().ToList()); }
/// <summary> /// Does this object have any dependent objects? (If it does have dependent objects, these would need to be deleted before this object could be deleted.) /// </summary> /// <returns></returns> public bool HasDependentObjects() { return(AgreementPeople.Any() || AuditLogs.Any() || FileResourcesWhereYouAreTheCreatePerson.Any() || GisUploadAttemptsWhereYouAreTheGisUploadAttemptCreatePerson.Any() || GrantAllocationsWhereYouAreTheGrantManager.Any() || GrantAllocationAwardPersonnelAndBenefitsLineItems.Any() || GrantAllocationAwardTravelLineItems.Any() || GrantAllocationChangeLogsWhereYouAreTheChangePerson.Any() || GrantAllocationNotesWhereYouAreTheCreatedByPerson.Any() || GrantAllocationNotesWhereYouAreTheLastUpdatedByPerson.Any() || GrantAllocationNoteInternalsWhereYouAreTheCreatedByPerson.Any() || GrantAllocationNoteInternalsWhereYouAreTheLastUpdatedByPerson.Any() || GrantAllocationProgramManagers.Any() || GrantModificationNoteInternalsWhereYouAreTheCreatedByPerson.Any() || GrantModificationNoteInternalsWhereYouAreTheLastUpdatedByPerson.Any() || GrantNotesWhereYouAreTheCreatedByPerson.Any() || GrantNotesWhereYouAreTheLastUpdatedByPerson.Any() || GrantNoteInternalsWhereYouAreTheCreatedByPerson.Any() || GrantNoteInternalsWhereYouAreTheLastUpdatedByPerson.Any() || InteractionEventsWhereYouAreTheStaffPerson.Any() || InteractionEventContacts.Any() || InvoicesWhereYouAreThePreparedByPerson.Any() || Notifications.Any() || OrganizationsWhereYouAreThePrimaryContactPerson.Any() || PerformanceMeasureNotesWhereYouAreTheCreatePerson.Any() || PerformanceMeasureNotesWhereYouAreTheUpdatePerson.Any() || PeopleWhereYouAreTheAddedByPerson.Any() || PersonAllowedAuthenticators.Any() || PersonRoles.Any() || PersonStewardOrganizations.Any() || PersonStewardRegions.Any() || PersonStewardTaxonomyBranches.Any() || ProgramsWhereYouAreTheProgramCreatePerson.Any() || ProgramsWhereYouAreTheProgramLastUpdatedByPerson.Any() || ProgramsWhereYouAreTheProgramPrimaryContactPerson.Any() || ProgramPeople.Any() || ProjectsWhereYouAreTheProposingPerson.Any() || ProjectsWhereYouAreTheReviewedByPerson.Any() || ProjectInternalNotesWhereYouAreTheCreatePerson.Any() || ProjectInternalNotesWhereYouAreTheUpdatePerson.Any() || ProjectLocationStagings.Any() || ProjectLocationStagingUpdates.Any() || ProjectNotesWhereYouAreTheCreatePerson.Any() || ProjectNotesWhereYouAreTheUpdatePerson.Any() || ProjectNoteUpdatesWhereYouAreTheCreatePerson.Any() || ProjectNoteUpdatesWhereYouAreTheUpdatePerson.Any() || ProjectPeople.Any() || ProjectPersonUpdates.Any() || ProjectUpdateBatchesWhereYouAreTheLastUpdatePerson.Any() || ProjectUpdateHistoriesWhereYouAreTheUpdatePerson.Any() || SupportRequestLogsWhereYouAreTheRequestPerson.Any() || SystemAttributesWhereYouAreThePrimaryContactPerson.Any() || TabularDataImportsWhereYouAreTheLastProcessedPerson.Any() || TabularDataImportsWhereYouAreTheUploadPerson.Any()); }