public IEnumerable <ValidationResult> Validate(ValidationContext validationContext)
        {
            if (ForProject)
            {
                var project      = HttpRequestStorage.DatabaseEntities.Projects.GetProject(PrimaryKeyID);
                var projectIsLoa = project.CreateGisUploadAttemptID.HasValue &&
                                   project.CreateGisUploadAttempt.GisUploadSourceOrganization
                                   .GisUploadSourceOrganizationName.Contains("LOA",
                                                                             StringComparison.InvariantCultureIgnoreCase);
                if (projectIsLoa && (ProjectGrantAllocationRequests == null || !ProjectGrantAllocationRequests.Any()))
                {
                    yield return(new ValidationResult("LOA Projects must have at least one Grant Allocation"));
                }
            }

            if (ProjectGrantAllocationRequests == null)
            {
                yield break;
            }

            if (ProjectGrantAllocationRequests.GroupBy(x => x.GrantAllocationID).Any(x => x.Count() > 1))
            {
                yield return(new ValidationResult("Each grant allocation can only be used once."));
            }

            //foreach (var projectGrantAllocationRequest in ProjectGrantAllocationRequests)
            //{
            //    if (projectGrantAllocationRequest.AreBothValuesZero())
            //    {
            //        var grantAllocation = HttpRequestStorage.DatabaseEntities.GrantAllocations.Single(x => x.GrantAllocationID == projectGrantAllocationRequest.GrantAllocationID);
            //        yield return new ValidationResult(
            //            $"Secured Funding and Unsecured Funding cannot both be zero for Grant Allocation: {grantAllocation.GrantAllocationName}. If the amount of secured or unsecured funding is unknown, you can leave the amounts blank.");
            //    }
            //}
        }
Ejemplo n.º 2
0
        //public decimal? UnfundedNeed()
        //{
        //    return EstimatedTotalCost - GetSecuredFunding();
        //}

        public decimal?GetTotalFunding()
        {
            return(ProjectGrantAllocationRequests.Any()
                ? (decimal?)ProjectGrantAllocationRequests.Sum(x => x.TotalAmount.GetValueOrDefault())
                : null);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Active Dependent type names of this object
        /// </summary>
        public List <string> DependentObjectNames()
        {
            var dependentObjects = new List <string>();

            if (GrantAllocationAwardLandownerCostShareLineItems.Any())
            {
                dependentObjects.Add(typeof(GrantAllocationAwardLandownerCostShareLineItem).Name);
            }

            if (InteractionEventProjects.Any())
            {
                dependentObjects.Add(typeof(InteractionEventProject).Name);
            }

            if (NotificationProjects.Any())
            {
                dependentObjects.Add(typeof(NotificationProject).Name);
            }

            if (PerformanceMeasureActuals.Any())
            {
                dependentObjects.Add(typeof(PerformanceMeasureActual).Name);
            }

            if (PerformanceMeasureExpecteds.Any())
            {
                dependentObjects.Add(typeof(PerformanceMeasureExpected).Name);
            }

            if (ProjectClassifications.Any())
            {
                dependentObjects.Add(typeof(ProjectClassification).Name);
            }

            if (ProjectCustomAttributes.Any())
            {
                dependentObjects.Add(typeof(ProjectCustomAttribute).Name);
            }

            if (ProjectDocuments.Any())
            {
                dependentObjects.Add(typeof(ProjectDocument).Name);
            }

            if (ProjectExemptReportingYears.Any())
            {
                dependentObjects.Add(typeof(ProjectExemptReportingYear).Name);
            }

            if (ProjectExternalLinks.Any())
            {
                dependentObjects.Add(typeof(ProjectExternalLink).Name);
            }

            if (ProjectFundingSources.Any())
            {
                dependentObjects.Add(typeof(ProjectFundingSource).Name);
            }

            if (ProjectGrantAllocationExpenditures.Any())
            {
                dependentObjects.Add(typeof(ProjectGrantAllocationExpenditure).Name);
            }

            if (ProjectGrantAllocationRequests.Any())
            {
                dependentObjects.Add(typeof(ProjectGrantAllocationRequest).Name);
            }

            if (ProjectImages.Any())
            {
                dependentObjects.Add(typeof(ProjectImage).Name);
            }

            if (ProjectInternalNotes.Any())
            {
                dependentObjects.Add(typeof(ProjectInternalNote).Name);
            }

            if (ProjectLocations.Any())
            {
                dependentObjects.Add(typeof(ProjectLocation).Name);
            }

            if (ProjectLocationStagings.Any())
            {
                dependentObjects.Add(typeof(ProjectLocationStaging).Name);
            }

            if (ProjectNotes.Any())
            {
                dependentObjects.Add(typeof(ProjectNote).Name);
            }

            if (ProjectOrganizations.Any())
            {
                dependentObjects.Add(typeof(ProjectOrganization).Name);
            }

            if (ProjectPeople.Any())
            {
                dependentObjects.Add(typeof(ProjectPerson).Name);
            }

            if (ProjectPriorityLandscapes.Any())
            {
                dependentObjects.Add(typeof(ProjectPriorityLandscape).Name);
            }

            if (ProjectPrograms.Any())
            {
                dependentObjects.Add(typeof(ProjectProgram).Name);
            }

            if (ProjectRegions.Any())
            {
                dependentObjects.Add(typeof(ProjectRegion).Name);
            }

            if (ProjectTags.Any())
            {
                dependentObjects.Add(typeof(ProjectTag).Name);
            }

            if (ProjectUpdateBatches.Any())
            {
                dependentObjects.Add(typeof(ProjectUpdateBatch).Name);
            }

            if (Treatments.Any())
            {
                dependentObjects.Add(typeof(Treatment).Name);
            }
            return(dependentObjects.Distinct().ToList());
        }
Ejemplo n.º 4
0
 /// <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(GrantAllocationAwardLandownerCostShareLineItems.Any() || InteractionEventProjects.Any() || NotificationProjects.Any() || PerformanceMeasureActuals.Any() || PerformanceMeasureExpecteds.Any() || ProjectClassifications.Any() || ProjectCustomAttributes.Any() || ProjectDocuments.Any() || ProjectExemptReportingYears.Any() || ProjectExternalLinks.Any() || ProjectFundingSources.Any() || ProjectGrantAllocationExpenditures.Any() || ProjectGrantAllocationRequests.Any() || ProjectImages.Any() || ProjectInternalNotes.Any() || ProjectLocations.Any() || ProjectLocationStagings.Any() || ProjectNotes.Any() || ProjectOrganizations.Any() || ProjectPeople.Any() || ProjectPriorityLandscapes.Any() || ProjectPrograms.Any() || ProjectRegions.Any() || ProjectTags.Any() || ProjectUpdateBatches.Any() || Treatments.Any());
 }
 /// <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(AgreementGrantAllocations.Any() || GrantAllocationAwards.Any() || GrantAllocationBudgetLineItems.Any() || GrantAllocationChangeLogs.Any() || GrantAllocationExpenditures.Any() || GrantAllocationFileResources.Any() || GrantAllocationNotes.Any() || GrantAllocationNoteInternals.Any() || GrantAllocationProgramIndexProjectCodes.Any() || GrantAllocationProgramManagers.Any() || InvoiceLineItems.Any() || ProjectGrantAllocationExpenditures.Any() || ProjectGrantAllocationExpenditureUpdates.Any() || ProjectGrantAllocationRequests.Any() || ProjectGrantAllocationRequestUpdates.Any());
 }
        /// <summary>
        /// Active Dependent type names of this object
        /// </summary>
        public List <string> DependentObjectNames()
        {
            var dependentObjects = new List <string>();

            if (AgreementGrantAllocations.Any())
            {
                dependentObjects.Add(typeof(AgreementGrantAllocation).Name);
            }

            if (GrantAllocationAwards.Any())
            {
                dependentObjects.Add(typeof(GrantAllocationAward).Name);
            }

            if (GrantAllocationBudgetLineItems.Any())
            {
                dependentObjects.Add(typeof(GrantAllocationBudgetLineItem).Name);
            }

            if (GrantAllocationChangeLogs.Any())
            {
                dependentObjects.Add(typeof(GrantAllocationChangeLog).Name);
            }

            if (GrantAllocationExpenditures.Any())
            {
                dependentObjects.Add(typeof(GrantAllocationExpenditure).Name);
            }

            if (GrantAllocationFileResources.Any())
            {
                dependentObjects.Add(typeof(GrantAllocationFileResource).Name);
            }

            if (GrantAllocationNotes.Any())
            {
                dependentObjects.Add(typeof(GrantAllocationNote).Name);
            }

            if (GrantAllocationNoteInternals.Any())
            {
                dependentObjects.Add(typeof(GrantAllocationNoteInternal).Name);
            }

            if (GrantAllocationProgramIndexProjectCodes.Any())
            {
                dependentObjects.Add(typeof(GrantAllocationProgramIndexProjectCode).Name);
            }

            if (GrantAllocationProgramManagers.Any())
            {
                dependentObjects.Add(typeof(GrantAllocationProgramManager).Name);
            }

            if (InvoiceLineItems.Any())
            {
                dependentObjects.Add(typeof(InvoiceLineItem).Name);
            }

            if (ProjectGrantAllocationExpenditures.Any())
            {
                dependentObjects.Add(typeof(ProjectGrantAllocationExpenditure).Name);
            }

            if (ProjectGrantAllocationExpenditureUpdates.Any())
            {
                dependentObjects.Add(typeof(ProjectGrantAllocationExpenditureUpdate).Name);
            }

            if (ProjectGrantAllocationRequests.Any())
            {
                dependentObjects.Add(typeof(ProjectGrantAllocationRequest).Name);
            }

            if (ProjectGrantAllocationRequestUpdates.Any())
            {
                dependentObjects.Add(typeof(ProjectGrantAllocationRequestUpdate).Name);
            }
            return(dependentObjects.Distinct().ToList());
        }