Esempio n. 1
0
        public ForwardLookingFactSheetViewData(Person currentPerson,
                                               Models.Project project,
                                               ProjectLocationSummaryMapInitJson projectLocationSummaryMapInitJson,
                                               GoogleChartJson googleChartJson,
                                               List <GooglePieChartSlice> grantAllocationRequestAmountGooglePieChartSlices, Models.FirmaPage firmaPageFactSheetCustomText) : base(currentPerson, project)
        {
            PageTitle       = project.DisplayName;
            BreadCrumbTitle = "Fact Sheet";

            PerformanceMeasureExpectedValues = project.PerformanceMeasureExpecteds.GroupBy(x => x.PerformanceMeasure, new HavePrimaryKeyComparer <Models.PerformanceMeasure>())
                                               .OrderBy(x => x.Key.PerformanceMeasureSortOrder).ThenBy(x => x.Key.PerformanceMeasureDisplayName).ToList();

            KeyPhoto = project.KeyPhoto;
            ProjectImagesExceptKeyPhotoGroupedByTiming = project.ProjectImages.Where(x => !x.IsKeyPhoto && x.ProjectImageTiming != ProjectImageTiming.Unknown && !x.ExcludeFromFactSheet)
                                                         .GroupBy(x => x.ProjectImageTiming).OrderBy(x => x.Key.SortOrder).ToList();
            ProjectImagesPerTimingGroup = ProjectImagesExceptKeyPhotoGroupedByTiming.Count == 1 ? 6 : 2;
            Classifications             = project.ProjectClassifications.Select(x => x.Classification).ToList().SortByOrderThenName().ToList();

            ProjectLocationSummaryMapInitJson = projectLocationSummaryMapInitJson;
            GoogleChartJson = googleChartJson;
            GrantAllocationRequestAmountGooglePieChartSlices = grantAllocationRequestAmountGooglePieChartSlices;

            //Dynamically resize chart based on how much space the legend requires
            CalculatedChartHeight = 350 - (GrantAllocationRequestAmountGooglePieChartSlices.Count <= 2
                                        ? GrantAllocationRequestAmountGooglePieChartSlices.Count * 24
                                        : GrantAllocationRequestAmountGooglePieChartSlices.Count * 20);
            FactSheetPdfUrl = SitkaRoute <ProjectController> .BuildUrlFromExpression(c => c.FactSheetPdf(project));

            if (project.ProjectType == null)
            {
                TaxonomyColor = "blue";
            }
            else
            {
                switch (MultiTenantHelpers.GetTaxonomyLevel().ToEnum)
                {
                case TaxonomyLevelEnum.Leaf:
                    TaxonomyColor = project.ProjectType.ThemeColor;
                    break;

                case TaxonomyLevelEnum.Branch:
                    TaxonomyColor = project.ProjectType.TaxonomyBranch.ThemeColor;
                    break;

                case TaxonomyLevelEnum.Trunk:
                    TaxonomyColor = project.ProjectType.TaxonomyBranch.TaxonomyTrunk.ThemeColor;
                    break;
                }
            }

            ProjectTypeName             = project.ProjectType == null ? $"{Models.FieldDefinition.Project.GetFieldDefinitionLabel()} Taxonomy Not Set" : project.ProjectType.DisplayName;
            TaxonomyBranchName          = project.ProjectType == null ? $"{Models.FieldDefinition.Project.GetFieldDefinitionLabel()} Taxonomy Not Set" : project.ProjectType.TaxonomyBranch.DisplayName;
            ProjectTypeDisplayName      = Models.FieldDefinition.ProjectType.GetFieldDefinitionLabel();
            EstimatedTotalCost          = Project.EstimatedTotalCost.HasValue ? Project.EstimatedTotalCost.ToStringCurrency() : "";
            NoGrantAllocationIdentified = project.GetNoGrantAllocationIdentifiedAmount() != null?Project.GetNoGrantAllocationIdentifiedAmount().ToStringCurrency() : "";

            GrandAllocation             = project.ProjectGrantAllocationRequests.Any() ? project.ProjectGrantAllocationRequests.Sum(x => x.TotalAmount).ToStringCurrency() : ViewUtilities.Unknown;
            CustomFactSheetTextViewData = new ViewPageContentViewData(firmaPageFactSheetCustomText, false);
        }
        public BackwardLookingFactSheetViewData(Person currentPerson, Models.Project project,
                                                ProjectLocationSummaryMapInitJson projectLocationSummaryMapInitJson,
                                                GoogleChartJson projectFactSheetGoogleChart,
                                                List <GooglePieChartSlice> expenditureGooglePieChartSlices, List <string> chartColorRange,
                                                Models.FirmaPage firmaPageFactSheet) : base(currentPerson, project)
        {
            PageTitle       = project.DisplayName;
            BreadCrumbTitle = "Fact Sheet";

            EstimatedTotalCost          = Project.EstimatedTotalCost.HasValue ? Project.EstimatedTotalCost.ToStringCurrency() : "";
            NoGrantAllocationIdentified = project.GetNoGrantAllocationIdentifiedAmount() != null?Project.GetNoGrantAllocationIdentifiedAmount().ToStringCurrency() : "";

            TotalFunding = Project.GetTotalFunding() != null?Project.GetTotalFunding().ToStringCurrency() : "";

            const bool userCanAddPhotosToThisProject = false;
            var        newPhotoForProjectUrl         = string.Empty;
            var        selectKeyImageUrl             = string.Empty;
            var        galleryName = $"ProjectImage{project.ProjectID}";

            ImageGalleryViewData = new ImageGalleryViewData(currentPerson,
                                                            galleryName,
                                                            project.ProjectImages,
                                                            userCanAddPhotosToThisProject,
                                                            newPhotoForProjectUrl,
                                                            selectKeyImageUrl,
                                                            true,
                                                            x => x.CaptionOnFullView,
                                                            "Photo");

            PerformanceMeasureReportedValues =
                project.GetReportedPerformanceMeasures().GroupBy(x => x.PerformanceMeasure).OrderBy(x => x.Key.PerformanceMeasureSortOrder).ThenBy(x => x.Key.PerformanceMeasureDisplayName).ToList();

            ChartID  = $"fundingChartForProject{project.ProjectID}";
            KeyPhoto = project.KeyPhoto;
            ProjectImagesExceptKeyPhotoGroupedByTiming =
                project.ProjectImages.Where(x => !x.IsKeyPhoto && x.ProjectImageTiming != ProjectImageTiming.Unknown && !x.ExcludeFromFactSheet)
                .GroupBy(x => x.ProjectImageTiming)
                .OrderBy(x => x.Key.SortOrder)
                .ToList();
            ProjectImagesPerTimingGroup = ProjectImagesExceptKeyPhotoGroupedByTiming.Count == 1 ? 6 : 2;
            Classifications             = project.ProjectClassifications.Select(x => x.Classification).ToList().SortByOrderThenName().ToList();

            ProjectLocationSummaryMapInitJson = projectLocationSummaryMapInitJson;
            GoogleChartJson = projectFactSheetGoogleChart;

            ExpenditureGooglePieChartSlices = expenditureGooglePieChartSlices;
            ChartColorRange = chartColorRange;
            //Dynamically resize chart based on how much space the legend requires
            CalculatedChartHeight = 350 - ExpenditureGooglePieChartSlices.Count * 19;
            FactSheetPdfUrl       = SitkaRoute <ProjectController> .BuildUrlFromExpression(c => c.FactSheetPdf(project));

            if (project.ProjectType == null)
            {
                TaxonomyColor = "blue";
            }
            else
            {
                switch (MultiTenantHelpers.GetTaxonomyLevel().ToEnum)
                {
                case TaxonomyLevelEnum.Leaf:
                    TaxonomyColor = project.ProjectType.ThemeColor;
                    break;

                case TaxonomyLevelEnum.Branch:
                    TaxonomyColor = project.ProjectType.TaxonomyBranch.ThemeColor;
                    break;

                case TaxonomyLevelEnum.Trunk:
                    TaxonomyColor = project.ProjectType.TaxonomyBranch.TaxonomyTrunk.ThemeColor;
                    break;
                }
            }
            ProjectTypeName                 = project.ProjectType == null ? $"{Models.FieldDefinition.Project.GetFieldDefinitionLabel()} Taxonomy Not Set" : project.ProjectType.DisplayName;
            TaxonomyBranchName              = project.ProjectType == null ? $"{Models.FieldDefinition.Project.GetFieldDefinitionLabel()} Taxonomy Not Set" : project.ProjectType.TaxonomyBranch.DisplayName;
            ProjectTypeDisplayName          = Models.FieldDefinition.ProjectType.GetFieldDefinitionLabel();
            PrimaryContactPerson            = project.GetPrimaryContact();
            CustomFactSheetPageTextViewData = new ViewPageContentViewData(firmaPageFactSheet, false);
        }