Example #1
0
        public static ProjectUpdateBatch CreateNewProjectUpdateBatchForProject(Project project, FirmaSession currentFirmaSession)
        {
            Check.Require(project.ProjectUpdateBatches.All(x => x.ProjectUpdateState == ProjectUpdateState.Approved), "Cannot create a new Project Update Batch, there is already an active update for this project.");

            var projectUpdateBatch = CreateProjectUpdateBatchAndLogTransition(project, currentFirmaSession);

            // basics & map
            projectUpdateBatch.CreateFromProject();

            // expenditures
            ProjectFundingSourceExpenditureUpdateModelExtensions.CreateFromProject(projectUpdateBatch);

            // project expenditures relevant cost types
            ProjectRelevantCostTypeUpdateModelExtensions.CreateExpendituresRelevantCostTypesFromProject(projectUpdateBatch);
            ProjectRelevantCostTypeUpdateModelExtensions.CreateBudgetsRelevantCostTypesFromProject(projectUpdateBatch);

            // expenditures exempt explanation
            projectUpdateBatch.SyncExpendituresYearsExemptionExplanation();

            // Expected Funding
            ProjectFundingSourceBudgetUpdateModelExtensions.CreateFromProject(projectUpdateBatch);
            ProjectNoFundingSourceIdentifiedUpdateModelExtensions.CreateFromProject(projectUpdateBatch);

            // expected performance measures
            PerformanceMeasureExpectedUpdateModelExtensions.CreateFromProject(projectUpdateBatch);

            // reported performance measures
            PerformanceMeasureActualUpdateModelExtensions.CreateFromProject(projectUpdateBatch);

            // project performance measures exempt reporting years
            ProjectExemptReportingYearUpdateModelExtensions.CreatePerformanceMeasuresExemptReportingYearsFromProject(projectUpdateBatch);

            // project exempt reporting years reason
            projectUpdateBatch.SyncPerformanceMeasureActualYearsExemptionExplanation();

            // project locations - detailed
            ProjectLocationUpdateModelExtensions.CreateFromProject(projectUpdateBatch);

            // project geospatialArea
            ProjectGeospatialAreaUpdateModelExtensions.CreateFromProject(projectUpdateBatch);

            // photos
            ProjectImageUpdateModelExtensions.CreateFromProject(projectUpdateBatch);
            projectUpdateBatch.IsPhotosUpdated = false;

            // external links
            ProjectExternalLinkUpdateModelExtensions.CreateFromProject(projectUpdateBatch);

            // notes
            ProjectNoteUpdateModelExtensions.CreateFromProject(projectUpdateBatch);

            // organizations
            ProjectOrganizationUpdateModelExtensions.CreateFromProject(projectUpdateBatch);

            //Contacts
            ProjectContactUpdateModelExtensions.CreateFromProject(projectUpdateBatch);

            // Attachments
            ProjectAttachmentUpdateModelExtensions.CreateFromProject(projectUpdateBatch);

            // Custom attributes
            ProjectCustomAttributeUpdateModelExtensions.CreateFromProject(projectUpdateBatch);

            //Classifications
            ProjectClassificationsUpdateModelExtensions.CreateFromProject(projectUpdateBatch);

            // Technical Assistance Requests - for Idaho
            TechnicalAssistanceRequestUpdateModelExtensions.CreateFromProject(projectUpdateBatch);

            return(projectUpdateBatch);
        }