public static Enumeration GetAgentToAgentRolesCodes(bool isInverseRole = true) { Enumeration entity = new Enumeration(); using (var context = new EntityContext()) { EM.Tables.Codes_PropertyCategory category = context.Codes_PropertyCategory .SingleOrDefault(s => s.Id == CodesManager.PROPERTY_CATEGORY_CREDENTIAL_AGENT_ROLE); if (category != null && category.Id > 0) { entity.Id = category.Id; entity.Name = category.Title; entity.SchemaName = category.SchemaName; entity.Url = category.SchemaUrl; entity.Items = new List <EnumeratedItem>(); EnumeratedItem val = new EnumeratedItem(); var Query = from P in context.Codes_CredentialAgentRelationship .Where(s => s.IsActive == true && s.IsAgentToAgentRole == true) select P; Query = Query.OrderBy(p => p.Title); var results = Query.ToList(); foreach (EM.Tables.Codes_CredentialAgentRelationship item in results) { val = new EnumeratedItem(); val.Id = item.Id; val.CodeId = item.Id; val.Value = item.Id.ToString();//???? val.Description = item.Description; if (isInverseRole) { val.Name = item.ReverseRelation; } else { val.Name = item.Title; } if ((bool)item.IsQARole) { val.IsQAValue = true; if (IsDevEnv()) { val.Name += " (QA)"; } } entity.Items.Add(val); } } } return(entity); }
private static Enumeration GetEntityToOrgQARolesCodes(bool isInverseRole, int qaRoleState, bool getAll, int parentEntityTypeId) { Enumeration entity = new Enumeration(); using (var context = new EntityContext()) { EM.Tables.Codes_PropertyCategory category = context.Codes_PropertyCategory .SingleOrDefault(s => s.Id == CodesManager.PROPERTY_CATEGORY_CREDENTIAL_AGENT_ROLE); if (category != null && category.Id > 0) { entity.Id = category.Id; entity.Name = category.Title; entity.SchemaName = category.SchemaName; entity.Url = category.SchemaUrl; entity.Items = new List <EnumeratedItem>(); EnumeratedItem val = new EnumeratedItem(); //18-02-07 all entities have the same QA roles at this time //( parentEntityTypeId == 1 && s.IsCredentialsConnectionType == true ) || //( parentEntityTypeId == 3 && s.IsAssessmentAgentRole == true ) || //( parentEntityTypeId == 7 && s.IsLearningOppAgentRole == true ) var results = context.Codes_CredentialAgentRelationship .Where(s => s.IsActive == true && (bool)s.IsQARole == true) .OrderBy(p => p.Title) .ToList(); foreach (EM.Tables.Codes_CredentialAgentRelationship item in results) { val = new EnumeratedItem(); val.Id = item.Id; val.CodeId = item.Id; val.Value = item.Id.ToString();//???? val.Description = item.Description; if (isInverseRole) { val.Name = item.ReverseRelation; } else { val.Name = item.Title; //val.Description = string.Format( "{0} is {1} by this Organization ", entityType, item.Title ); } if (( bool )item.IsQARole) { val.IsQAValue = true; } if (parentEntityTypeId == 3) { val.Totals = item.AssessmentTotals ?? 0; } else if (parentEntityTypeId == 2) { val.Totals = item.OrganizationTotals ?? 0; } else if (parentEntityTypeId == 7) { val.Totals = item.LoppTotals ?? 0; } else if (parentEntityTypeId == 1) { val.Totals = item.CredentialTotals ?? 0; } if (IsDevEnv()) { val.Name += string.Format(" ({0})", val.Totals); } if (getAll || val.Totals > 0) { entity.Items.Add(val); } } } } return(entity); }
private static Enumeration GetEntityToOrgRolesCodes(bool isInverseRole, int qaRoleState, bool getAll, string entityType) { Enumeration entity = new Enumeration(); using (var context = new EntityContext()) { EM.Tables.Codes_PropertyCategory category = context.Codes_PropertyCategory .SingleOrDefault(s => s.Id == CodesManager.PROPERTY_CATEGORY_CREDENTIAL_AGENT_ROLE); if (category != null && category.Id > 0) { entity.Id = category.Id; entity.Name = category.Title; entity.SchemaName = category.SchemaName; entity.Url = category.SchemaUrl; entity.Items = new List <EnumeratedItem>(); EnumeratedItem val = new EnumeratedItem(); //var sortedList = context.Codes_CredentialAgentRelationship // .Where( s => s.IsActive == true && ( qaOnlyRoles == false || s.IsQARole == true) ) // .OrderBy( x => x.Title ) // .ToList(); var Query = from P in context.Codes_CredentialAgentRelationship .Where(s => s.IsActive == true) select P; if (qaRoleState == 1) //qa only { Query = Query.Where(p => p.IsQARole == true); } else if (qaRoleState == 2) { //this is state is for showing org roles for a credential. //16-06-01 mp - for now show qa and no qa, just skip agent to agent which for now is dept and Subsidiary if (entityType.ToLower() == "credential") { Query = Query.Where(p => p.IsEntityToAgentRole == true); } else { Query = Query.Where(p => p.IsQARole == false && p.IsEntityToAgentRole == true); } } else //all { } Query = Query.OrderBy(p => p.Title); var results = Query.ToList(); //add Select option //need to only do if for a dropdown, not a checkbox list if (qaRoleState == 1) { //val = new EnumeratedItem(); //val.Id = 0; //val.CodeId = val.Id; //val.Name = "Select an Action"; //val.Description = ""; //val.SortOrder = 0; //val.Value = val.Id.ToString(); //entity.Items.Add( val ); } //foreach ( Codes_PropertyValue item in category.Codes_PropertyValue ) foreach (EM.Tables.Codes_CredentialAgentRelationship item in results) { val = new EnumeratedItem(); val.Id = item.Id; val.CodeId = item.Id; val.Value = item.Id.ToString();//???? val.Description = item.Description; if (isInverseRole) { val.Name = item.ReverseRelation; //if ( string.IsNullOrWhiteSpace( entityType ) ) //{ // //may not matter // val.Description = string.Format( "Organization has {0} service.", item.ReverseRelation ); //} //else //{ // val.Description = string.Format( "Organization {0} this {1}", item.ReverseRelation, entityType ); //} } else { val.Name = item.Title; //val.Description = string.Format( "{0} is {1} by this Organization ", entityType, item.Title ); } if ((bool)item.IsQARole) { val.IsQAValue = true; if (IsDevEnv()) { val.Name += " (QA)"; } } entity.Items.Add(val); } } } return(entity); }