Пример #1
0
        public ActionResult Duplicate(GrantAllocationPrimaryKey grantAllocationPrimaryKey, EditGrantAllocationViewModel viewModel)
        {
            var originalGrantAllocation = grantAllocationPrimaryKey.EntityObject;

            Check.EnsureNotNull(originalGrantAllocation);
            var relevantGrant = originalGrantAllocation.GrantModification.Grant;

            if (!ModelState.IsValid)
            {
                // 6/29/20 TK (SLG EDIT) - Null is correct here. the Grant Allocation passed in is used to get any "Program Managers" assigned on
                // a Grant Allocation that may have lost their "program manager" permissions
                return(GrantAllocationViewEdit(viewModel, EditGrantAllocationType.NewGrantAllocation, null, relevantGrant));
            }

            var grantModification = HttpRequestStorage.DatabaseEntities.GrantModifications.Single(gm => gm.GrantModificationID == viewModel.GrantModificationID);

            // Sanity check for alignment
            Check.Ensure(relevantGrant.GrantID == grantModification.GrantID);
            var grantAllocation = GrantAllocation.CreateNewBlank(grantModification);

            viewModel.UpdateModel(grantAllocation, CurrentPerson);
            grantAllocation.CreateAllGrantAllocationBudgetLineItemsByCostType();
            SetMessageForDisplay($"{FieldDefinition.GrantAllocation.GetFieldDefinitionLabel()} \"{grantAllocation.GrantAllocationName}\" has been created.");
            return(new ModalDialogFormJsonResult());
        }
Пример #2
0
        public PartialViewResult NewGrantAllocationFiles(GrantAllocationPrimaryKey grantAllocationPrimaryKey)
        {
            Check.EnsureNotNull(grantAllocationPrimaryKey.EntityObject);
            var viewModel = new NewFileViewModel();

            return(ViewNewGrantAllocationFiles(viewModel));
        }
Пример #3
0
        public ActionResult NewGrantAllocationBudgetLineItem(GrantAllocationPrimaryKey grantAllocationPrimaryKey)
        {
            var grantAllocation = grantAllocationPrimaryKey.EntityObject;
            var viewModel       = new EditGrantAllocationBudgetLineItemViewModel(grantAllocation);

            return(ViewEditGrantAllocationBudgetLineItem(viewModel));
        }
Пример #4
0
        public PartialViewResult Edit(GrantAllocationPrimaryKey grantAllocationPrimaryKey)
        {
            var grantAllocation = grantAllocationPrimaryKey.EntityObject;

            Check.EnsureNotNull(grantAllocation);
            var relevantGrant = grantAllocation.GrantModification.Grant;
            var viewModel     = new EditGrantAllocationViewModel(grantAllocation);

            return(GrantAllocationViewEdit(viewModel, EditGrantAllocationType.ExistingGrantAllocation, grantAllocation, relevantGrant));
        }
        public PartialViewResult NewForAGrantAllocation(GrantAllocationPrimaryKey grantAllocationPrimaryKey)
        {
            var grantAllocation = grantAllocationPrimaryKey.EntityObject;
            var viewModel       = new EditGrantAllocationAwardViewModel()
            {
                GrantAllocationID = grantAllocation.GrantAllocationID
            };

            return(GrantAllocationAwardViewEdit(viewModel));
        }
Пример #6
0
        public ViewResult GrantAllocationDetail(GrantAllocationPrimaryKey grantAllocationPrimaryKey)
        {
            var grantAllocation = grantAllocationPrimaryKey.EntityObject;

            if (grantAllocation == null)
            {
                throw new Exception($"Could not find GrantAllocationID # {grantAllocationPrimaryKey.PrimaryKeyValue}; has it been deleted?");
            }

            var taxonomyLevel = MultiTenantHelpers.GetTaxonomyLevel();
            var grantAllocationBasicsViewData         = new GrantAllocationBasicsViewData(grantAllocation, false, taxonomyLevel);
            var userHasEditGrantAllocationPermissions = new GrantAllocationEditAsAdminFeature().HasPermissionByPerson(CurrentPerson);
            var grantAllocationNotesViewData          = new EntityNotesViewData(
                EntityNote.CreateFromEntityNote(new List <IEntityNote>(grantAllocation.GrantAllocationNotes)),
                SitkaRoute <GrantAllocationController> .BuildUrlFromExpression(x => x.NewGrantAllocationNote(grantAllocationPrimaryKey)),
                grantAllocation.GrantAllocationName,
                userHasEditGrantAllocationPermissions);
            var grantAllocationNoteInternalsViewData = new EntityNotesViewData(
                EntityNote.CreateFromEntityNote(new List <IEntityNote>(grantAllocation.GrantAllocationNoteInternals)),
                SitkaRoute <GrantAllocationController> .BuildUrlFromExpression(x => x.NewGrantAllocationNoteInternal(grantAllocationPrimaryKey)),
                grantAllocation.GrantAllocationName,
                userHasEditGrantAllocationPermissions);

            var costTypes = CostType.All.Where(x => x.IsValidInvoiceLineItemCostType).OrderBy(x => x.CostTypeDisplayName).ToList();

            const string chartTitle       = "Grant Allocation Expenditures";
            var          chartContainerID = chartTitle.Replace(" ", "");

            // If ProjectGrantAllocationExpenditures is empty, ToGoogleChart returns null...
            var googleChart = grantAllocation.GrantAllocationExpenditures
                              .ToGoogleChart(x => x.CostType?.CostTypeDisplayName,
                                             costTypes.Select(x => x.CostTypeDisplayName).ToList(),
                                             x => x.CostType?.CostTypeDisplayName,
                                             chartContainerID,
                                             grantAllocation.DisplayName);

            // Which makes this guy bork (bork bork bork)
            googleChart?.GoogleChartConfiguration.Legend.SetLegendPosition(GoogleChartLegendPosition.Top);
            var viewGoogleChartViewData = new ViewGoogleChartViewData(googleChart, chartTitle, 350, false);

            var projectGrantAllocationRequestsGridSpec = new ProjectGrantAllocationRequestsGridSpec()
            {
                ObjectNameSingular  = "Project",
                ObjectNamePlural    = "Projects",
                SaveFiltersInCookie = true
            };

            var grantAllocationExpendituresGridSpec = new GrantAllocationExpendituresGridSpec();
            var grantAllocationAwardsGridSpec       = new GrantAllocationAwardGridSpec(CurrentPerson, grantAllocation);

            var viewData = new Views.GrantAllocation.DetailViewData(CurrentPerson, grantAllocation, grantAllocationBasicsViewData, grantAllocationNotesViewData, grantAllocationNoteInternalsViewData, viewGoogleChartViewData, projectGrantAllocationRequestsGridSpec, grantAllocationExpendituresGridSpec, grantAllocationAwardsGridSpec);

            return(RazorView <Views.GrantAllocation.Detail, Views.GrantAllocation.DetailViewData>(viewData));
        }
Пример #7
0
        public ActionResult NewGrantAllocationFiles(GrantAllocationPrimaryKey grantAllocationPrimaryKey, NewFileViewModel viewModel)
        {
            var grantAllocation = grantAllocationPrimaryKey.EntityObject;

            if (!ModelState.IsValid)
            {
                return(ViewNewGrantAllocationFiles(new NewFileViewModel()));
            }

            viewModel.UpdateModel(grantAllocation, CurrentPerson);
            SetMessageForDisplay($"Successfully created {viewModel.FileResourcesData.Count} new files(s) for {FieldDefinition.GrantAllocation.GetFieldDefinitionLabel()} \"{grantAllocation.GrantAllocationName}\".");
            return(new ModalDialogFormJsonResult());
        }
        public ActionResult NewForAGrantAllocation(GrantAllocationPrimaryKey grantAllocationPrimaryKey, EditGrantAllocationAwardViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                return(GrantAllocationAwardViewEdit(viewModel));
            }
            var grantAllocation      = HttpRequestStorage.DatabaseEntities.GrantAllocations.Single(ga => ga.GrantAllocationID == viewModel.GrantAllocationID);
            var focusArea            = HttpRequestStorage.DatabaseEntities.FocusAreas.Single(fa => fa.FocusAreaID == viewModel.FocusAreaID);
            var grantAllocationAward = GrantAllocationAward.CreateNewBlank(grantAllocation, focusArea);

            viewModel.UpdateModel(grantAllocationAward);
            return(new ModalDialogFormJsonResult());
        }
Пример #9
0
        public ActionResult Edit(GrantAllocationPrimaryKey grantAllocationPrimaryKey, EditGrantAllocationViewModel viewModel)
        {
            var grantAllocation = grantAllocationPrimaryKey.EntityObject;

            Check.EnsureNotNull(grantAllocation);
            if (!ModelState.IsValid)
            {
                return(GrantAllocationViewEdit(viewModel, EditGrantAllocationType.ExistingGrantAllocation, grantAllocation, grantAllocation.GrantModification.Grant));
            }
            viewModel.UpdateModel(grantAllocation, CurrentPerson);
            SetMessageForDisplay($"{FieldDefinition.GrantAllocation.GetFieldDefinitionLabel()} \"{grantAllocation.GrantAllocationName}\" has been updated.");
            return(new ModalDialogFormJsonResult());
        }
Пример #10
0
        public ActionResult NewGrantAllocationNoteInternal(GrantAllocationPrimaryKey grantAllocationPrimaryKey, EditGrantAllocationNoteInternalViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                return(ViewEditGrantAllocationNoteInternal(viewModel, EditGrantAllocationNoteInternalType.NewNote));
            }
            var grantAllocation             = grantAllocationPrimaryKey.EntityObject;
            var grantAllocationNoteInternal = GrantAllocationNoteInternal.CreateNewBlank(grantAllocation, CurrentPerson);

            viewModel.UpdateModel(grantAllocationNoteInternal, CurrentPerson, EditGrantAllocationNoteType.NewNote);
            HttpRequestStorage.DatabaseEntities.GrantAllocationNoteInternals.Add(grantAllocationNoteInternal);
            SetMessageForDisplay($"New {FieldDefinition.GrantAllocationNoteInternal.GetFieldDefinitionLabel()} has been created.");
            return(new ModalDialogFormJsonResult());
        }
Пример #11
0
        public ActionResult DeleteGrantAllocation(GrantAllocationPrimaryKey grantAllocationPrimaryKey, ConfirmDialogFormViewModel viewModel)
        {
            var grantAllocation = grantAllocationPrimaryKey.EntityObject;

            if (!ModelState.IsValid)
            {
                return(ViewDeleteGrantAllocation(grantAllocation, viewModel));
            }

            var message = $"{FieldDefinition.GrantAllocation.GetFieldDefinitionLabel()} \"{grantAllocation.GrantAllocationName}\" successfully deleted.";

            grantAllocation.DeleteFullAndChildless(HttpRequestStorage.DatabaseEntities);
            SetMessageForDisplay(message);
            return(new ModalDialogFormJsonResult());
        }
Пример #12
0
        public PartialViewResult Duplicate(GrantAllocationPrimaryKey grantAllocationPrimaryKey)
        {
            var originalGrantAllocation = grantAllocationPrimaryKey.EntityObject;

            Check.EnsureNotNull(originalGrantAllocation);
            var relevantGrant = originalGrantAllocation.GrantModification.Grant;

            // Copy original grant allocation to new view model, except for the grant mod and allocation amount
            var viewModel = new EditGrantAllocationViewModel(originalGrantAllocation);

            viewModel.GrantModificationID = 0;
            viewModel.AllocationAmount    = null;
            viewModel.GrantAllocationName = $"{viewModel.GrantAllocationName} - Copy";

            // 6/29/20 TK (SLG EDIT) - Null is correct here. the Grant Allocation passed in is used to get any "Program Managers" assigned on
            // a Grant Allocation that may have lost their "program manager" permissions
            return(GrantAllocationViewEdit(viewModel, EditGrantAllocationType.NewGrantAllocation, null, relevantGrant));
        }
Пример #13
0
        public ActionResult NewGrantAllocationBudgetLineItem(GrantAllocationPrimaryKey grantAllocationPrimaryKey, EditGrantAllocationBudgetLineItemViewModel viewModel)
        {
            var grantAllocation = grantAllocationPrimaryKey.EntityObject;

            if (!ModelState.IsValid)
            {
                return(ViewEditGrantAllocationBudgetLineItem(viewModel));
            }

            var grantAllocationBudgetLineItem = new GrantAllocationBudgetLineItem(viewModel.GrantAllocationID, viewModel.CostTypeID, viewModel.GrantAllocationBudgetLineItemAmount);

            viewModel.UpdateModel(grantAllocationBudgetLineItem);
            HttpRequestStorage.DatabaseEntities.GrantAllocationBudgetLineItems.Add(grantAllocationBudgetLineItem);
            HttpRequestStorage.DatabaseEntities.SaveChanges();
            SetMessageForDisplay($"{FieldDefinition.GrantAllocationBudgetLineItem.GetFieldDefinitionLabel()} successfully added to this {FieldDefinition.GrantAllocation.GetFieldDefinitionLabel()}.");

            return(new ModalDialogFormJsonResult());
        }
Пример #14
0
        public GridJsonNetJObjectResult <BudgetVsActualLineItem> GrantAllocationBudgetVsActualsGridJsonData(GrantAllocationPrimaryKey grantAllocationPrimaryKey)
        {
            var grantAllocation = grantAllocationPrimaryKey.EntityObject;
            var gridSpec        = new GrantAllocationBudgetVsActualsGridSpec();

            var grantAllocationBudgetVsActualLineItems = grantAllocation.GetAllBudgetVsActualLineItemsByCostType();

            var gridJsonNetJObjectResult = new GridJsonNetJObjectResult <BudgetVsActualLineItem>(grantAllocationBudgetVsActualLineItems, gridSpec);

            return(gridJsonNetJObjectResult);
        }
Пример #15
0
        public GridJsonNetJObjectResult <GrantAllocationExpenditure> GrantAllocationExpendituresGridJsonData(GrantAllocationPrimaryKey grantAllocationPrimaryKey)
        {
            var grantAllocation             = grantAllocationPrimaryKey.EntityObject;
            var grantAllocationExpenditures = grantAllocation.GrantAllocationExpenditures.ToList();
            var gridSpec = new GrantAllocationExpendituresGridSpec();
            var gridJsonNetJObjectResult = new GridJsonNetJObjectResult <GrantAllocationExpenditure>(grantAllocationExpenditures, gridSpec);

            return(gridJsonNetJObjectResult);
        }
Пример #16
0
        public PartialViewResult NewGrantAllocationNoteInternal(GrantAllocationPrimaryKey grantAllocationPrimaryKey)
        {
            var viewModel = new EditGrantAllocationNoteInternalViewModel();

            return(ViewEditGrantAllocationNoteInternal(viewModel, EditGrantAllocationNoteInternalType.NewNote));
        }
Пример #17
0
        public GridJsonNetJObjectResult <GrantAllocationBudgetLineItem> GrantAllocationBudgetLineItemGridJsonData(GrantAllocationPrimaryKey grantAllocationPrimaryKey)
        {
            var grantAllocation = grantAllocationPrimaryKey.EntityObject;
            var gridSpec        = new GrantAllocationBudgetLineItemGridSpec(CurrentPerson, grantAllocation);

            var grantAllocationBudgetLineItems = grantAllocation.GrantAllocationBudgetLineItems.ToList();

            var gridJsonNetJObjectResult = new GridJsonNetJObjectResult <GrantAllocationBudgetLineItem>(grantAllocationBudgetLineItems, gridSpec);

            return(gridJsonNetJObjectResult);
        }
Пример #18
0
        public GridJsonNetJObjectResult <ProjectCalendarYearExpenditure> ProjectCalendarYearExpendituresGridJsonData(GrantAllocationPrimaryKey grantAllocationPrimaryKey)
        {
            var grantAllocation = grantAllocationPrimaryKey.EntityObject;
            var projectGrantAllocationExpenditures = grantAllocation.ProjectGrantAllocationExpenditures.ToList();
            var calendarYearRangeForExpenditures   =
                projectGrantAllocationExpenditures.CalculateCalendarYearRangeForExpenditures(grantAllocation);
            var gridSpec = new ProjectCalendarYearExpendituresGridSpec(calendarYearRangeForExpenditures);
            var projectGrantAllocations  = ProjectCalendarYearExpenditure.CreateFromProjectsAndCalendarYears(projectGrantAllocationExpenditures, calendarYearRangeForExpenditures);
            var gridJsonNetJObjectResult = new GridJsonNetJObjectResult <ProjectCalendarYearExpenditure>(projectGrantAllocations, gridSpec);

            return(gridJsonNetJObjectResult);
        }
Пример #19
0
        public PartialViewResult DeleteGrantAllocation(GrantAllocationPrimaryKey grantAllocationPrimaryKey)
        {
            var viewModel = new ConfirmDialogFormViewModel(grantAllocationPrimaryKey.PrimaryKeyValue);

            return(ViewDeleteGrantAllocation(grantAllocationPrimaryKey.EntityObject, viewModel));
        }
Пример #20
0
        public GridJsonNetJObjectResult <GrantAllocationAward> GrantAllocationAwardsGridJsonData(GrantAllocationPrimaryKey grantAllocationPrimaryKey)
        {
            var grantAllocation       = grantAllocationPrimaryKey.EntityObject;
            var grantAllocationAwards = grantAllocation.GrantAllocationAwards.ToList();
            var gridSpec = new GrantAllocationAwardGridSpec(CurrentPerson, grantAllocation);
            var gridJsonNetJObjectResult = new GridJsonNetJObjectResult <GrantAllocationAward>(grantAllocationAwards, gridSpec);

            return(gridJsonNetJObjectResult);
        }
Пример #21
0
        public GridJsonNetJObjectResult <ProjectGrantAllocationRequest> ProjectGrantAllocationRequestsGridJsonData(GrantAllocationPrimaryKey grantAllocationPrimaryKey)
        {
            var grantAllocation = grantAllocationPrimaryKey.EntityObject;
            var projectGrantAllocationRequests = grantAllocation.ProjectGrantAllocationRequests.ToList();
            var gridSpec = new ProjectGrantAllocationRequestsGridSpec();
            var gridJsonNetJObjectResult = new GridJsonNetJObjectResult <ProjectGrantAllocationRequest>(projectGrantAllocationRequests, gridSpec);

            return(gridJsonNetJObjectResult);
        }