예제 #1
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));
        }
예제 #2
0
        public PartialViewResult New(GrantPrimaryKey grantPrimaryKey)
        {
            Grant relevantGrant = grantPrimaryKey.EntityObject;
            var   viewModel     = new EditGrantAllocationViewModel();

            // Pre-populate allocation dates from the grant
            viewModel.StartDate = relevantGrant.StartDate;
            viewModel.EndDate   = relevantGrant.EndDate;
            // 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));
        }
예제 #3
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));
        }
예제 #4
0
        private PartialViewResult GrantAllocationViewEdit(EditGrantAllocationViewModel viewModel,
                                                          EditGrantAllocationType editGrantAllocationType,
                                                          GrantAllocation grantAllocationBeingEdited,
                                                          Grant optionalRelevantGrant)
        {
            if (editGrantAllocationType == EditGrantAllocationType.ExistingGrantAllocation)
            {
                // Sanity check; this should always agree for an existing one
                Check.Ensure(optionalRelevantGrant.GrantID == grantAllocationBeingEdited.GrantModification.Grant.GrantID);
            }
            var organizations    = HttpRequestStorage.DatabaseEntities.Organizations.GetActiveOrganizations();
            var grantTypes       = HttpRequestStorage.DatabaseEntities.GrantTypes;
            var grants           = HttpRequestStorage.DatabaseEntities.Grants.ToList();
            var divisions        = Division.All;
            var regions          = HttpRequestStorage.DatabaseEntities.DNRUplandRegions;
            var federalFundCodes = HttpRequestStorage.DatabaseEntities.FederalFundCodes;
            var people           = HttpRequestStorage.DatabaseEntities.People.ToList();
            List <GrantModification> grantModifications;

            if (optionalRelevantGrant == null)
            {
                grantModifications = HttpRequestStorage.DatabaseEntities.GrantModifications.ToList();
            }
            else
            {
                grantModifications = optionalRelevantGrant.GrantModifications.ToList();
            }

            var viewData = new EditGrantAllocationViewData(editGrantAllocationType,
                                                           grantAllocationBeingEdited,
                                                           organizations,
                                                           grantTypes,
                                                           grants,
                                                           grantModifications,
                                                           divisions,
                                                           regions,
                                                           federalFundCodes,
                                                           people
                                                           );

            return(RazorPartialView <EditGrantAllocation, EditGrantAllocationViewData, EditGrantAllocationViewModel>(viewData, viewModel));
        }
예제 #5
0
        public ActionResult New(GrantPrimaryKey grantPrimaryKey, EditGrantAllocationViewModel viewModel)
        {
            Grant relevantGrant = grantPrimaryKey.EntityObject;

            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());
        }
예제 #6
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());
        }