public Organization GetOrganizationContainingProjectSimpleLocation(IProject project, bool userCanViewPrivateLocations) { if (!(HasOrganizationsWithSpatialBoundary() && IsOrganizationRelationshipTypeRequired)) { return(null); } if (project.HasProjectLocationPoint(userCanViewPrivateLocations)) { return(null); } var organizationsInThisRelatonshipTypeWithBoundary = OrganizationTypeOrganizationRelationshipTypes.SelectMany(x => x.OrganizationType.Organizations.Where(y => y.OrganizationBoundary != null)); return(organizationsInThisRelatonshipTypeWithBoundary.FirstOrDefault(x => { try { var projectLocationPoint = project.GetProjectLocationPoint(userCanViewPrivateLocations); var contains = projectLocationPoint != null && x.OrganizationBoundary.Contains(projectLocationPoint); return contains; } catch (Exception e) { SitkaLogger.Instance.LogDetailedErrorMessage(e); //This typically trips if there are geometries with no SRID return false; } })); }
/// <summary> /// Dependent type names of this entity /// </summary> public void DeleteChildren(DatabaseEntities dbContext) { foreach (var x in Organizations.ToList()) { x.DeleteFull(dbContext); } foreach (var x in OrganizationTypeOrganizationRelationshipTypes.ToList()) { x.DeleteFull(dbContext); } }
/// <summary> /// Active Dependent type names of this object /// </summary> public List <string> DependentObjectNames() { var dependentObjects = new List <string>(); if (Organizations.Any()) { dependentObjects.Add(typeof(Organization).Name); } if (OrganizationTypeOrganizationRelationshipTypes.Any()) { dependentObjects.Add(typeof(OrganizationTypeOrganizationRelationshipType).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(Organizations.Any() || OrganizationTypeOrganizationRelationshipTypes.Any()); }
public bool IsAssociatedWithOrganizationType(OrganizationType organizationType) { return(OrganizationTypeOrganizationRelationshipTypes.Select(x => x.OrganizationType).Contains(organizationType)); }
public bool HasOrganizationsWithSpatialBoundary() { return(OrganizationTypeOrganizationRelationshipTypes.Any(x => x.OrganizationType.Organizations.Any(y => y.OrganizationBoundary != null))); }