Esempio n. 1
0
        public PartialViewResult NewGrantFiles(GrantPrimaryKey grantPrimaryKey)
        {
            Check.EnsureNotNull(grantPrimaryKey.EntityObject);
            var viewModel = new NewFileViewModel();

            return(ViewNewGrantFiles(viewModel));
        }
Esempio n. 2
0
        public PartialViewResult Edit(GrantPrimaryKey grantPrimaryKey)
        {
            var grant     = grantPrimaryKey.EntityObject;
            var viewModel = new EditGrantViewModel(grant);

            return(ViewEdit(viewModel, EditGrantType.ExistingGrant));
        }
Esempio n. 3
0
        public ActionResult Duplicate(GrantPrimaryKey grantPrimaryKey, DuplicateGrantViewModel viewModel)
        {
            var originalGrant = grantPrimaryKey.EntityObject;

            Check.EnsureNotNull(originalGrant);

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

            if (!ModelState.IsValid)
            {
                return(DuplicateGrantViewEdit(viewModel, originalGrant, initialAwardGrantModificationForCopy.GrantAllocations.ToList()));
            }

            var grantStatus  = HttpRequestStorage.DatabaseEntities.GrantStatuses.Single(gs => gs.GrantStatusID == viewModel.GrantStatusID);
            var organization = originalGrant.Organization;
            var newGrant     = Grant.CreateNewBlank(grantStatus, organization);

            viewModel.UpdateModel(newGrant);
            newGrant.CFDANumber  = originalGrant.CFDANumber;
            newGrant.GrantTypeID = originalGrant.GrantTypeID;

            var newGrantModification = GrantModification.CreateNewBlank(newGrant, initialAwardGrantModificationForCopy.GrantModificationStatus);

            newGrantModification.GrantModificationAmount    = viewModel.GrantModificationAmount ?? 0;
            newGrantModification.GrantModificationStartDate = viewModel.GrantStartDate ?? DateTime.Today;
            newGrantModification.GrantModificationEndDate   = viewModel.GrantEndDate ?? DateTime.Today;
            newGrantModification.GrantModificationName      = GrantModificationPurpose.InitialAward.GrantModificationPurposeName;
            var newGrantModificationPurpose = GrantModificationGrantModificationPurpose.CreateNewBlank(newGrantModification, GrantModificationPurpose.InitialAward);

            if (viewModel.GrantAllocationsToDuplicate != null && viewModel.GrantAllocationsToDuplicate.Any())
            {
                foreach (var allocationID in viewModel.GrantAllocationsToDuplicate)
                {
                    var allocationToCopy =
                        HttpRequestStorage.DatabaseEntities.GrantAllocations.Single(ga =>
                                                                                    ga.GrantAllocationID == allocationID);
                    var newAllocation = GrantAllocation.CreateNewBlank(newGrantModification);
                    newAllocation.GrantAllocationName = allocationToCopy.GrantAllocationName;
                    newAllocation.StartDate           = allocationToCopy.StartDate;
                    newAllocation.EndDate             = allocationToCopy.EndDate;

                    // 10/7/20 TK - not sure we wanna copy these but going for it anyways
                    newAllocation.FederalFundCodeID = allocationToCopy.FederalFundCodeID;
                    newAllocation.OrganizationID    = allocationToCopy.OrganizationID;
                    newAllocation.DNRUplandRegionID = allocationToCopy.DNRUplandRegionID;
                    newAllocation.DivisionID        = allocationToCopy.DivisionID;
                    newAllocation.GrantManagerID    = allocationToCopy.GrantManagerID;

                    // 10/7/20 TK - make sure we setup the budgetLineItems for the new allocation
                    newAllocation.CreateAllGrantAllocationBudgetLineItemsByCostType();
                }
            }

            //need to save changes here, because otherwise the MessageForDisplay will link to an item with a negative ID, causing errors
            HttpRequestStorage.DatabaseEntities.SaveChanges();
            SetMessageForDisplay($"{FieldDefinition.Grant.GetFieldDefinitionLabel()} \"{UrlTemplate.MakeHrefString(newGrant.GetDetailUrl(), newGrant.GrantName)}\" has been created.");
            return(new ModalDialogFormJsonResult());
            //return RedirectToAction(new SitkaRoute<GrantController>(gc => gc.GrantDetail(newGrant.GrantID)));
        }
 public ActionResult Edit(GrantPrimaryKey grantPrimaryKey, EditGrantViewModel viewModel)
 {
     var grant = grantPrimaryKey.EntityObject;
     if (!ModelState.IsValid)
     {
         return ViewEdit(viewModel,  EditGrantType.ExistingGrant);
     }
     viewModel.UpdateModel(grant, CurrentPerson);
     SetMessageForDisplay($"{FieldDefinition.Grant.GetFieldDefinitionLabel()} \"{grant.GrantName}\" has been updated.");
     return new ModalDialogFormJsonResult();
 }
Esempio n. 5
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));
        }
        public ActionResult NewGrantFiles(GrantPrimaryKey grantPrimaryKey, NewFileViewModel viewModel)
        {
            var grant = grantPrimaryKey.EntityObject;
            if (!ModelState.IsValid)
            {
                return ViewNewGrantFiles(new NewFileViewModel());
            }

            viewModel.UpdateModel(grant, CurrentPerson);
            SetMessageForDisplay($"Successfully created {viewModel.FileResourcesData.Count} new files(s) for {FieldDefinition.Grant.GetFieldDefinitionLabel()} \"{grant.GrantName}\".");
            return new ModalDialogFormJsonResult();
        }
        public ActionResult DeleteGrant(GrantPrimaryKey grantPrimaryKey, ConfirmDialogFormViewModel viewModel)
        {
            var grant = grantPrimaryKey.EntityObject;
            if (!ModelState.IsValid)
            {
                return ViewDeleteGrant(grant, viewModel);
            }

            var message = $"{FieldDefinition.Grant.GetFieldDefinitionLabel()} \"{grant.GrantTitle}\" successfully deleted.";
            grant.DeleteFullAndChildless(HttpRequestStorage.DatabaseEntities);
            SetMessageForDisplay(message);
            return new ModalDialogFormJsonResult();
        }
 public ActionResult NewGrantNote(GrantPrimaryKey grantPrimaryKey, EditGrantNoteViewModel viewModel)
 {
     if (!ModelState.IsValid)
     {
         return ViewEditNote(viewModel, EditGrantNoteType.NewNote);
     }
     var grant = grantPrimaryKey.EntityObject;
     var grantNote = GrantNote.CreateNewBlank(grant, CurrentPerson);
     viewModel.UpdateModel(grantNote, CurrentPerson, EditGrantNoteType.NewNote);
     HttpRequestStorage.DatabaseEntities.GrantNotes.Add(grantNote);
     SetMessageForDisplay($"{FieldDefinition.GrantNote.GetFieldDefinitionLabel()} has been created.");
     return new ModalDialogFormJsonResult();
 }
Esempio n. 9
0
        public GridJsonNetJObjectResult <Agreement> GrantAgreementGridJsonData(GrantPrimaryKey grantPrimaryKey)
        {
            // 2/4/22 TK - need to walk "grant -> grant mod -> grant allocation -> AgreementGrantAllocation -> Agreement"
            var grant                     = grantPrimaryKey.EntityObject;
            var grantMods                 = grant.GrantModifications;
            var grantAllocations          = grantMods.SelectMany(x => x.GrantAllocations);
            var agreementGrantAllocations = grantAllocations.SelectMany(x => x.AgreementGrantAllocations);
            var agreements                = agreementGrantAllocations.Select(x => x.Agreement).ToList();

            var gridSpec = new GrantAgreementGridSpec();
            var gridJsonNetJObjectResult = new GridJsonNetJObjectResult <Agreement>(agreements, gridSpec);

            return(gridJsonNetJObjectResult);
        }
        public ActionResult NewGrantModificationForAGrant(GrantPrimaryKey grantPrimaryKey, EditGrantModificationViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                return(ViewEditGrantModification(viewModel, EditGrantModificationType.New));
            }
            var grantModificationStatus = HttpRequestStorage.DatabaseEntities.GrantModificationStatuses.Single(g => g.GrantModificationStatusID == viewModel.GrantModificationStatusID);
            var grant             = HttpRequestStorage.DatabaseEntities.Grants.FirstOrDefault(x => x.GrantID == viewModel.GrantID);
            var grantModification = GrantModification.CreateNewBlank(grant, grantModificationStatus);
            var allGrantModificationGrantModificationPurposes = HttpRequestStorage.DatabaseEntities.GrantModificationGrantModificationPurposes.ToList();

            viewModel.UpdateModel(grantModification, CurrentPerson, allGrantModificationGrantModificationPurposes);
            SetMessageForDisplay($"{FieldDefinition.GrantModification.GetFieldDefinitionLabel()} \"{grantModification.GrantModificationName}\" has been created.");
            return(new ModalDialogFormJsonResult());
        }
        public ViewResult GrantDetail(GrantPrimaryKey grantPrimaryKey)
        {
            var grant = grantPrimaryKey.EntityObject;
            var userHasEditGrantPermissions = new GrantEditAsAdminFeature().HasPermissionByPerson(CurrentPerson);
            var grantNotesViewData = new EntityNotesViewData(
                EntityNote.CreateFromEntityNote(new List<IEntityNote>(grant.GrantNotes)),
                SitkaRoute<GrantController>.BuildUrlFromExpression(x => x.NewGrantNote(grantPrimaryKey)),
                grant.GrantName,
                userHasEditGrantPermissions);

            var internalGrantNotesViewData = new EntityNotesViewData(
                EntityNote.CreateFromEntityNote(new List<IEntityNote>(grant.GrantNoteInternals)),
                SitkaRoute<GrantController>.BuildUrlFromExpression(x => x.NewGrantNoteInternal(grantPrimaryKey)),
                grant.GrantName,
                userHasEditGrantPermissions);
            var viewData = new Views.Grant.GrantDetailViewData(CurrentPerson, grant, grantNotesViewData, internalGrantNotesViewData);
            return RazorView<GrantDetail, GrantDetailViewData>(viewData);
        }
        public PartialViewResult Duplicate(GrantPrimaryKey grantPrimaryKey)
        {
            var grantToDuplicate = grantPrimaryKey.EntityObject;
            Check.EnsureNotNull(grantToDuplicate);

            //get the grant allocations for the initial award grant mod
            var grantModifications = grantToDuplicate.GrantModifications;
            var initialAwardGrantMod = grantModifications.FirstOrDefault(x =>
                x.GrantModificationGrantModificationPurposes.FirstOrDefault(gmp => gmp.GrantModificationPurposeID == GrantModificationPurpose.InitialAward.GrantModificationPurposeID) != null);
            List<GrantAllocation> grantAllocations = new List<GrantAllocation>();
            if (initialAwardGrantMod != null)
            {
                grantAllocations = initialAwardGrantMod.GrantAllocations.ToList();
            }

            var viewModel = new DuplicateGrantViewModel(grantToDuplicate, initialAwardGrantMod?.GrantModificationID ?? -1);
            return DuplicateGrantViewEdit(viewModel, grantToDuplicate, grantAllocations);
        }
Esempio n. 13
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());
        }
 public PartialViewResult NewGrantNote(GrantPrimaryKey grantPrimaryKey)
 {
     var viewModel = new EditGrantNoteViewModel();
     return ViewEditNote(viewModel, EditGrantNoteType.NewNote);
 }
        public PartialViewResult NewGrantModificationForAGrant(GrantPrimaryKey grantPrimaryKey)
        {
            var viewModel = new EditGrantModificationViewModel(grantPrimaryKey.EntityObject);

            return(ViewEditGrantModification(viewModel, EditGrantModificationType.New));
        }
Esempio n. 16
0
        public GridJsonNetJObjectResult <GrantAllocationBudgetLineItemForGrid> GrantAllocationBudgetLineItemGridJsonDataByGrant(GrantPrimaryKey grantPrimaryKey)
        {
            var relevantGrant = grantPrimaryKey.EntityObject;
            // Create button is irrelevant to this data-only usage
            var gridSpec                 = new GrantAllocationBudgetLineItemGridSpec();
            var grantAllocations         = relevantGrant.GrantModifications.SelectMany(gm => gm.GrantAllocations).ToList();
            var budgetLineItems          = grantAllocations.Select(ga => new GrantAllocationBudgetLineItemForGrid(ga)).ToList();
            var gridJsonNetJObjectResult = new GridJsonNetJObjectResult <GrantAllocationBudgetLineItemForGrid>(budgetLineItems, gridSpec);

            return(gridJsonNetJObjectResult);
        }
Esempio n. 17
0
        public PartialViewResult NewGrantNoteInternal(GrantPrimaryKey grantPrimaryKey)
        {
            var viewModel = new EditGrantNoteInternalViewModel();

            return(ViewEditNoteInternal(viewModel, EditGrantNoteInternalType.NewNote));
        }
Esempio n. 18
0
        public GridJsonNetJObjectResult <GrantModification> GrantModificationGridJsonDataByGrant(GrantPrimaryKey grantPrimaryKey)
        {
            var grant                    = grantPrimaryKey.EntityObject;
            var gridSpec                 = new GrantModificationGridSpec(CurrentPerson, grant);
            var grantModifications       = grant.GrantModifications.ToList();
            var gridJsonNetJObjectResult = new GridJsonNetJObjectResult <GrantModification>(grantModifications, gridSpec);

            return(gridJsonNetJObjectResult);
        }
Esempio n. 19
0
        public GridJsonNetJObjectResult <GrantAllocation> GrantAllocationGridJsonDataByGrant(GrantPrimaryKey grantPrimaryKey)
        {
            var relevantGrant = grantPrimaryKey.EntityObject;
            // Create button is irrelevant to this data-only usage
            var gridSpec                 = new GrantAllocationGridSpec(CurrentPerson, GrantAllocationGridSpec.GrantAllocationGridCreateButtonType.Hidden, relevantGrant);
            var grantAllocations         = relevantGrant.GrantModifications.SelectMany(gm => gm.GrantAllocations).ToList();
            var gridJsonNetJObjectResult = new GridJsonNetJObjectResult <GrantAllocation>(grantAllocations, gridSpec);

            return(gridJsonNetJObjectResult);
        }
Esempio n. 20
0
        public PartialViewResult DeleteGrant(GrantPrimaryKey grantPrimaryKey)
        {
            var viewModel = new ConfirmDialogFormViewModel(grantPrimaryKey.PrimaryKeyValue);

            return(ViewDeleteGrant(grantPrimaryKey.EntityObject, viewModel));
        }