/// <summary>
 /// Delete just the entity
 /// </summary>
 public void Delete(DatabaseEntities dbContext)
 {
     dbContext.ProjectDocumentUpdates.Remove(this);
 }
 /// <summary>
 /// Delete just the entity
 /// </summary>
 public void Delete(DatabaseEntities dbContext)
 {
     dbContext.Projects.Remove(this);
 }
 /// <summary>
 /// Delete just the entity
 /// </summary>
 public void Delete(DatabaseEntities dbContext)
 {
     dbContext.Invoices.Remove(this);
 }
Beispiel #4
0
 /// <summary>
 /// Delete just the entity
 /// </summary>
 public void Delete(DatabaseEntities dbContext)
 {
     dbContext.GisUploadProgramMergeGroupings.Remove(this);
 }
 /// <summary>
 /// Delete just the entity
 /// </summary>
 public void Delete(DatabaseEntities dbContext)
 {
     dbContext.ProjectCustomAttributeTypes.Remove(this);
 }
Beispiel #6
0
 /// <summary>
 /// Delete just the entity
 /// </summary>
 public void Delete(DatabaseEntities dbContext)
 {
     dbContext.WashingtonCounties.Remove(this);
 }
        /// <summary>
        /// Dependent type names of this entity
        /// </summary>
        public void DeleteChildren(DatabaseEntities dbContext)
        {
            foreach (var x in AgreementsWhereYouAreTheAgreementFileResource.ToList())
            {
                x.DeleteFull(dbContext);
            }

            foreach (var x in ClassificationsWhereYouAreTheKeyImageFileResource.ToList())
            {
                x.DeleteFull(dbContext);
            }

            foreach (var x in CustomPageImages.ToList())
            {
                x.DeleteFull(dbContext);
            }

            foreach (var x in FieldDefinitionDataImages.ToList())
            {
                x.DeleteFull(dbContext);
            }

            foreach (var x in FirmaHomePageImages.ToList())
            {
                x.DeleteFull(dbContext);
            }

            foreach (var x in FirmaPageImages.ToList())
            {
                x.DeleteFull(dbContext);
            }

            foreach (var x in GrantAllocationAwardContractorInvoicesWhereYouAreTheGrantAllocationAwardContractorInvoiceFileResource.ToList())
            {
                x.DeleteFull(dbContext);
            }

            foreach (var x in GrantAllocationFileResources.ToList())
            {
                x.DeleteFull(dbContext);
            }

            foreach (var x in GrantFileResources.ToList())
            {
                x.DeleteFull(dbContext);
            }

            foreach (var x in GrantModificationFileResources.ToList())
            {
                x.DeleteFull(dbContext);
            }

            foreach (var x in InteractionEventFileResources.ToList())
            {
                x.DeleteFull(dbContext);
            }

            foreach (var x in InvoicesWhereYouAreTheInvoiceFileResource.ToList())
            {
                x.DeleteFull(dbContext);
            }

            foreach (var x in OrganizationsWhereYouAreTheLogoFileResource.ToList())
            {
                x.DeleteFull(dbContext);
            }

            foreach (var x in PriorityLandscapeFileResources.ToList())
            {
                x.DeleteFull(dbContext);
            }

            foreach (var x in ProjectDocuments.ToList())
            {
                x.DeleteFull(dbContext);
            }

            foreach (var x in ProjectDocumentUpdates.ToList())
            {
                x.DeleteFull(dbContext);
            }

            foreach (var x in ProjectImages.ToList())
            {
                x.DeleteFull(dbContext);
            }

            foreach (var x in ProjectImageUpdates.ToList())
            {
                x.DeleteFull(dbContext);
            }

            foreach (var x in SystemAttributesWhereYouAreTheBannerLogoFileResource.ToList())
            {
                x.DeleteFull(dbContext);
            }

            foreach (var x in SystemAttributesWhereYouAreTheSquareLogoFileResource.ToList())
            {
                x.DeleteFull(dbContext);
            }
        }
Beispiel #8
0
        private static List <GeospatialAreaStaging> ConvertToGeospatialStagings(string responseData, DatabaseEntities dbContext, string databaseConnectionString)
        {
            var featureCollection =
                JsonConvert.DeserializeObject <FeatureCollection>(responseData, new GeometryConverter());

            if (!featureCollection.Features.Any())
            {
                throw new Exception("No geospatial area features were returned from the endpoint.");
            }

            // Clear out staging table
            var tenantID         = HttpRequestStorage.Tenant.TenantID;
            var stagingsToDelete = dbContext.GeospatialAreaStagings.ToList();

            dbContext.AllGeospatialAreaStagings.RemoveRange(stagingsToDelete);
            dbContext.SaveChangesWithNoAuditing(tenantID);

            var ogr2OgrCommandLineRunner = new Ogr2OgrCommandLineRunner(FirmaWebConfiguration.Ogr2OgrExecutable,
                                                                        Ogr2OgrCommandLineRunner.DefaultCoordinateSystemId,
                                                                        FirmaWebConfiguration.HttpRuntimeExecutionTimeout.TotalMilliseconds);

            ogr2OgrCommandLineRunner.ImportGeoJsonToMsSql(responseData,
                                                          databaseConnectionString,
                                                          "GeospatialAreaStaging",
                                                          $"SELECT {tenantID} as TenantID, Name as Name, GlobalID as ExternalID",
                                                          false);
            return(dbContext.GeospatialAreaStagings.ToList());
        }
Beispiel #9
0
        public static string ProcessApiResponse(GeospatialAreaType geospatialAreaType,
                                                string responseData, DatabaseEntities dbContext, string databaseConnectionString)
        {
            var geospatialAreaTypeID   = geospatialAreaType.GeospatialAreaTypeID;
            var geospatialAreaStagings = ConvertToGeospatialStagings(responseData, dbContext, databaseConnectionString);
            var stagedExternalIDs      = geospatialAreaStagings.Select(x => x.ExternalID).ToList();
            var currentExternalIDs     = dbContext.GeospatialAreas.Where(x => x.GeospatialAreaTypeID == geospatialAreaTypeID).Select(x => x.ExternalID).ToList();
            var newGeospatialAreas     = geospatialAreaStagings.Where(x => !currentExternalIDs.Contains(x.ExternalID))
                                         .Select(x => new GeospatialArea(x.Name, geospatialAreaTypeID, x.Name)
            {
                ExternalID = x.ExternalID, GeospatialAreaFeature = x.Geometry
            }).ToList();

            dbContext.AllGeospatialAreas.AddRange(newGeospatialAreas);
            // Find entities with matching names in DB and Service
            var geospatialAreasToUpdate = dbContext.GeospatialAreas.Where(x => x.GeospatialAreaTypeID == geospatialAreaTypeID && stagedExternalIDs.Contains(x.ExternalID));

            if (geospatialAreasToUpdate.Any())
            {
                foreach (var geospatialArea in geospatialAreasToUpdate)
                {
                    // Get the corresponding feature from staging
                    var geospatialAreaStaging = geospatialAreaStagings.Single(x => x.ExternalID == geospatialArea.ExternalID);
                    // Update certain properties
                    geospatialArea.GeospatialAreaName      = geospatialAreaStaging.Name;
                    geospatialArea.GeospatialAreaShortName = geospatialAreaStaging.Name;
                    geospatialArea.GeospatialAreaFeature   = geospatialAreaStaging.Geometry;
                }
            }

            var geospatialAreasToPotentiallyDelete =
                dbContext.GeospatialAreas.Where(x => x.GeospatialAreaTypeID == geospatialAreaTypeID && !stagedExternalIDs.Contains(x.ExternalID)).ToList();

            if (geospatialAreasToPotentiallyDelete.Any())
            {
                var skippedDeletions = new List <string>();

                foreach (var geospatialArea in geospatialAreasToPotentiallyDelete)
                {
                    if (!geospatialArea.HasDependentObjects())
                    {
                        geospatialArea.Delete(dbContext);
                    }
                    else
                    {
                        skippedDeletions.Add($"<li>{geospatialArea.GeospatialAreaName}</li>");
                    }
                }

                if (skippedDeletions.Any())
                {
                    var geospatialAreaTypeName = HttpRequestStorage.DatabaseEntities.GeospatialAreaTypes
                                                 .Single(x => x.GeospatialAreaTypeID == geospatialAreaTypeID).GeospatialAreaTypeNamePluralized;
                    var skippedDeletionWarning = $"The following {geospatialAreaTypeName} were not found in the service but could not be deleted because they are still associated with other entities: " +
                                                 "<ul>" +
                                                 string.Join("", skippedDeletions.OrderBy(x => x)) +
                                                 "</ul>" +
                                                 "To delete them, remove their associations and re-run the sync.";
                    return(skippedDeletionWarning);
                }
            }

            return(null);
        }
 /// <summary>
 /// Delete just the entity
 /// </summary>
 public void Delete(DatabaseEntities dbContext)
 {
     dbContext.GrantAllocationFileResources.Remove(this);
 }
Beispiel #11
0
 /// <summary>
 /// Delete just the entity
 /// </summary>
 public void Delete(DatabaseEntities dbContext)
 {
     dbContext.Treatments.Remove(this);
 }
Beispiel #12
0
 /// <summary>
 /// Delete just the entity
 /// </summary>
 public void Delete(DatabaseEntities dbContext)
 {
     dbContext.AgreementGrantAllocations.Remove(this);
 }
Beispiel #13
0
 /// <summary>
 /// Delete just the entity
 /// </summary>
 public void Delete(DatabaseEntities dbContext)
 {
     dbContext.OrganizationTypes.Remove(this);
 }
Beispiel #14
0
 /// <summary>
 /// Delete just the entity
 /// </summary>
 public void Delete(DatabaseEntities dbContext)
 {
     dbContext.tmpAgreementContactsImportTemplates.Remove(this);
 }
 /// <summary>
 /// Delete just the entity
 /// </summary>
 public void Delete(DatabaseEntities dbContext)
 {
     dbContext.LoaStages.Remove(this);
 }
 /// <summary>
 /// Delete just the entity
 /// </summary>
 public void Delete(DatabaseEntities dbContext)
 {
     dbContext.ProgramIndices.Remove(this);
 }
Beispiel #17
0
 /// <summary>
 /// Delete just the entity
 /// </summary>
 public void Delete(DatabaseEntities dbContext)
 {
     dbContext.GrantModifications.Remove(this);
 }
 /// <summary>
 /// Delete just the entity
 /// </summary>
 public void Delete(DatabaseEntities dbContext)
 {
     dbContext.GrantAllocationAwardSuppliesLineItems.Remove(this);
 }
 /// <summary>
 /// Delete just the entity
 /// </summary>
 public void Delete(DatabaseEntities dbContext)
 {
     dbContext.FileResources.Remove(this);
 }
 /// <summary>
 /// Delete just the entity
 /// </summary>
 public void Delete(DatabaseEntities dbContext)
 {
     dbContext.FileResourceMimeTypeFileExtensions.Remove(this);
 }
 /// <summary>
 /// Delete just the entity
 /// </summary>
 public void Delete(DatabaseEntities dbContext)
 {
     dbContext.GisUploadAttempts.Remove(this);
 }
 /// <summary>
 /// Delete just the entity
 /// </summary>
 public void Delete(DatabaseEntities dbContext)
 {
     dbContext.ProjectGrantAllocationExpenditures.Remove(this);
 }
        public static void CommitChangesToProject(ProjectUpdateBatch projectUpdateBatch, DatabaseEntities databaseEntities)
        {
            var project = projectUpdateBatch.Project;
            var projectCustomAttributesFromProjectUpdate = projectUpdateBatch.ProjectCustomAttributeUpdates
                                                           .Select(x => new ProjectCustomAttribute(project.ProjectID, x.ProjectCustomAttributeType.ProjectCustomAttributeTypeID))
                                                           .ToList();
            var projectCustomAttributeValuesFromProjectUpdate = projectUpdateBatch.ProjectCustomAttributeUpdates
                                                                .SelectMany(x => x.ProjectCustomAttributeUpdateValues)
                                                                .Select(x =>
            {
                var projectCustomAttributeID =
                    project.ProjectCustomAttributes.SingleOrDefault(y =>
                                                                    y.ProjectCustomAttributeTypeID ==
                                                                    x.GetIProjectCustomAttribute()?.ProjectCustomAttributeTypeID)
                    ?.ProjectCustomAttributeID ??
                    projectCustomAttributesFromProjectUpdate.Single(y =>
                                                                    y.ProjectCustomAttributeTypeID ==
                                                                    x.GetIProjectCustomAttribute()?.ProjectCustomAttributeTypeID).ProjectCustomAttributeID;
                return(new ProjectCustomAttributeValue(projectCustomAttributeID, x.AttributeValue));
            })
                                                                .ToList();
            var existingProjectCustomAttributes = project.ProjectCustomAttributes.ToList();

            existingProjectCustomAttributes.Merge(projectCustomAttributesFromProjectUpdate,
                                                  (a, b) => a.ProjectID == b.ProjectID && a.ProjectCustomAttributeTypeID == b.ProjectCustomAttributeTypeID, databaseEntities);
            existingProjectCustomAttributes.SelectMany(x => x.ProjectCustomAttributeValues)
            .ToList()
            .Merge(projectCustomAttributeValuesFromProjectUpdate,
                   (x, y) => x.ProjectCustomAttributeValueID == y.ProjectCustomAttributeValueID, databaseEntities);
        }
 /// <summary>
 /// Delete just the entity
 /// </summary>
 public void Delete(DatabaseEntities dbContext)
 {
     dbContext.PerformanceMeasureActuals.Remove(this);
 }
Beispiel #25
0
 /// <summary>
 /// Delete just the entity
 /// </summary>
 public void Delete(DatabaseEntities dbContext)
 {
     dbContext.ProjectLocationUpdates.Remove(this);
 }
 /// <summary>
 /// Delete just the entity
 /// </summary>
 public void Delete(DatabaseEntities dbContext)
 {
     dbContext.GrantAllocationChangeLogs.Remove(this);
 }
        /// <summary>
        /// Dependent type names of this entity
        /// </summary>
        public void DeleteChildren(DatabaseEntities dbContext)
        {
            foreach (var x in GrantAllocationAwardLandownerCostShareLineItems.ToList())
            {
                x.DeleteFull(dbContext);
            }

            foreach (var x in InteractionEventProjects.ToList())
            {
                x.DeleteFull(dbContext);
            }

            foreach (var x in NotificationProjects.ToList())
            {
                x.DeleteFull(dbContext);
            }

            foreach (var x in PerformanceMeasureActuals.ToList())
            {
                x.DeleteFull(dbContext);
            }

            foreach (var x in PerformanceMeasureExpecteds.ToList())
            {
                x.DeleteFull(dbContext);
            }

            foreach (var x in ProjectClassifications.ToList())
            {
                x.DeleteFull(dbContext);
            }

            foreach (var x in ProjectCustomAttributes.ToList())
            {
                x.DeleteFull(dbContext);
            }

            foreach (var x in ProjectDocuments.ToList())
            {
                x.DeleteFull(dbContext);
            }

            foreach (var x in ProjectExemptReportingYears.ToList())
            {
                x.DeleteFull(dbContext);
            }

            foreach (var x in ProjectExternalLinks.ToList())
            {
                x.DeleteFull(dbContext);
            }

            foreach (var x in ProjectFundingSources.ToList())
            {
                x.DeleteFull(dbContext);
            }

            foreach (var x in ProjectGrantAllocationExpenditures.ToList())
            {
                x.DeleteFull(dbContext);
            }

            foreach (var x in ProjectGrantAllocationRequests.ToList())
            {
                x.DeleteFull(dbContext);
            }

            foreach (var x in ProjectImages.ToList())
            {
                x.DeleteFull(dbContext);
            }

            foreach (var x in ProjectInternalNotes.ToList())
            {
                x.DeleteFull(dbContext);
            }

            foreach (var x in ProjectLocations.ToList())
            {
                x.DeleteFull(dbContext);
            }

            foreach (var x in ProjectLocationStagings.ToList())
            {
                x.DeleteFull(dbContext);
            }

            foreach (var x in ProjectNotes.ToList())
            {
                x.DeleteFull(dbContext);
            }

            foreach (var x in ProjectOrganizations.ToList())
            {
                x.DeleteFull(dbContext);
            }

            foreach (var x in ProjectPeople.ToList())
            {
                x.DeleteFull(dbContext);
            }

            foreach (var x in ProjectPriorityLandscapes.ToList())
            {
                x.DeleteFull(dbContext);
            }

            foreach (var x in ProjectPrograms.ToList())
            {
                x.DeleteFull(dbContext);
            }

            foreach (var x in ProjectRegions.ToList())
            {
                x.DeleteFull(dbContext);
            }

            foreach (var x in ProjectTags.ToList())
            {
                x.DeleteFull(dbContext);
            }

            foreach (var x in ProjectUpdateBatches.ToList())
            {
                x.DeleteFull(dbContext);
            }

            foreach (var x in Treatments.ToList())
            {
                x.DeleteFull(dbContext);
            }
        }
Beispiel #28
0
 /// <summary>
 /// Delete just the entity
 /// </summary>
 public void Delete(DatabaseEntities dbContext)
 {
     dbContext.ProjectFundingSources.Remove(this);
 }
 /// <summary>
 /// Delete entity plus all children
 /// </summary>
 public void DeleteFull(DatabaseEntities dbContext)
 {
     DeleteChildren(dbContext);
     Delete(dbContext);
 }
        public static void CommitChangesToProject(ProjectUpdateBatch projectUpdateBatch, DatabaseEntities databaseEntities)
        {
            var project = projectUpdateBatch.Project;
            var projectContactsFromProjectUpdate =
                projectUpdateBatch.ProjectContactUpdates.Select(
                    x => new ProjectContact(project.ProjectID, x.ContactID, x.ContactRelationshipTypeID)).ToList();

            project.ProjectContacts.Merge(projectContactsFromProjectUpdate,
                                          (x, y) => x.ContactID == y.ContactID && x.ContactRelationshipTypeID == y.ContactRelationshipTypeID,
                                          databaseEntities);
        }