예제 #1
0
        public ViewResult Detail(DNRUplandRegionPrimaryKey dnrUplandRegionPrimaryKey)
        {
            var region   = dnrUplandRegionPrimaryKey.EntityObject;
            var mapDivID = $"region_{region.DNRUplandRegionID}_Map";

            var associatedProjects = region.GetAssociatedProjects(CurrentPerson);
            var layers             = DNRUplandRegion.GetRegionAndAssociatedProjectLayers(region, associatedProjects);
            var mapInitJson        = new MapInitJson(mapDivID, 10, layers, new BoundingBox(region.DNRUplandRegionLocation));

            var grantAllocationExpenditures = new List <GrantAllocationExpenditure>();

            region.GrantAllocations.ForEach(x => grantAllocationExpenditures.AddRange(x.GrantAllocationExpenditures));
            var costTypes = CostType.GetLineItemCostTypes();

            const string chartTitle       = "Grant Allocation Expenditures By Cost Type";
            var          chartContainerID = chartTitle.Replace(" ", "");
            var          googleChart      = grantAllocationExpenditures.ToGoogleChart(x => x.CostType?.CostTypeDisplayName,
                                                                                      costTypes.Select(ct => ct.CostTypeDisplayName).ToList(),
                                                                                      x => x.CostType?.CostTypeDisplayName,
                                                                                      chartContainerID,
                                                                                      chartTitle);

            var viewGoogleChartViewData = new ViewGoogleChartViewData(googleChart, chartTitle, 405, true);

            var performanceMeasures = associatedProjects
                                      .SelectMany(x => x.PerformanceMeasureActuals)
                                      .Select(x => x.PerformanceMeasure).Distinct()
                                      .OrderBy(x => x.PerformanceMeasureDisplayName)
                                      .ToList();

            var viewData = new DetailViewData(CurrentPerson, region, mapInitJson, viewGoogleChartViewData, performanceMeasures);

            return(RazorView <Detail, DetailViewData>(viewData));
        }
예제 #2
0
        public GrantAllocationBudgetLineItemsViewData(Person currentPerson, Models.GrantAllocation grantAllocationBeingEdited, List <GrantAllocationBudgetLineItem> grantAllocationBudgetLineItems)
        {
            CostTypes         = CostType.GetLineItemCostTypes();
            GrantAllocationID = grantAllocationBeingEdited.GrantAllocationID;
            GrantAllocationBudgetLineItems = grantAllocationBudgetLineItems.OrderBy(x => x.CostType.SortOrder).ToList();

            PersonHasPermissionToEditBudgetLineItems = new GrantAllocationBudgetLineItemEditAsAdminFeature().HasPermissionByPerson(currentPerson);
            //This will prevent the JS from posting back if the user doesn't have permission to edit the budget line items
            if (PersonHasPermissionToEditBudgetLineItems)
            {
                FormPostUrl = SitkaRoute <GrantAllocationController> .BuildUrlFromExpression(x =>
                                                                                             x.EditGrantAllocationBudgetLineItemAjax(grantAllocationBeingEdited.PrimaryKey));
            }
        }