コード例 #1
0
        public void UpdateModel(Models.Project project,
                                List <Models.ProjectGrantAllocationRequest> currentProjectGrantAllocationRequests,
                                IList <Models.ProjectGrantAllocationRequest> allProjectGrantAllocationRequests,
                                List <ProjectFundingSource> currentProjectFundingSources,
                                IList <ProjectFundingSource> allProjectFundingSources)
        {
            //Update the ProjectGrantAllocationRequests
            var projectGrantAllocationRequestsUpdated = new List <Models.ProjectGrantAllocationRequest>();

            if (ProjectGrantAllocationRequestSimples != null)
            {
                // Completely rebuild the list
                projectGrantAllocationRequestsUpdated = ProjectGrantAllocationRequestSimples
                                                        .Select(x => x.ToProjectGrantAllocationRequest()).ToList();
            }

            currentProjectGrantAllocationRequests.Merge(projectGrantAllocationRequestsUpdated,
                                                        allProjectGrantAllocationRequests,
                                                        (x, y) => x.ProjectID == y.ProjectID && x.GrantAllocationID == y.GrantAllocationID,
                                                        (x, y) => { x.TotalAmount = y.TotalAmount; });

            //Update the ProjectFundingSources
            var projectFundingSourcesUpdated = new List <Models.ProjectFundingSource>();

            if (FundingSourceIDs != null && FundingSourceIDs.Any())
            {
                // Completely rebuild the list
                projectFundingSourcesUpdated = FundingSourceIDs.Select(x => new ProjectFundingSource(project.ProjectID, x)).ToList();
            }

            currentProjectFundingSources.Merge(projectFundingSourcesUpdated,
                                               allProjectFundingSources,
                                               (x, y) => x.ProjectID == y.ProjectID && x.FundingSourceID == y.FundingSourceID);

            //Update Project fields
            project.ProjectFundingSourceNotes = ProjectFundingSourceNotes;
            project.EstimatedTotalCost        = ProjectEstimatedTotalCost;
        }
コード例 #2
0
        public IEnumerable <ValidationResult> GetValidationResults()
        {
            if (ProjectGrantAllocationRequestSimples == null)
            {
                yield break;
            }

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

            //foreach (var projectGrantAllocationRequestSimple in ProjectGrantAllocationRequestSimples)
            //{
            //    if (projectGrantAllocationRequestSimple.AreBothValuesZero())
            //    {
            //        var grantAllocation =
            //            HttpRequestStorage.DatabaseEntities.GrantAllocations.Single(x =>
            //                x.GrantAllocationID == projectGrantAllocationRequestSimple.GrantAllocationID);
            //        yield return new ValidationResult(
            //            $"Secured Funding and Unsecured Funding cannot both be zero for Grant Allocation: {grantAllocation.DisplayName}. If the amount of secured or unsecured funding is unknown, you can leave the amounts blank.");
            //    }
            //}
        }