Exemplo n.º 1
0
        private PartialViewResult ViewDeleteGrantAllocation(GrantAllocation grantAllocation, ConfirmDialogFormViewModel viewModel)
        {
            var confirmMessage = $"Are you sure you want to delete this {FieldDefinition.GrantAllocation.GetFieldDefinitionLabel()} '{grantAllocation.GrantAllocationName}'?";
            var viewData       = new ConfirmDialogFormViewData(confirmMessage, true);

            return(RazorPartialView <ConfirmDialogForm, ConfirmDialogFormViewData, ConfirmDialogFormViewModel>(viewData, viewModel));
        }
Exemplo n.º 2
0
            public static GrantAllocation Create(GrantModification grantModification, string grantAllocationName)
            {
                var grantAllocation = new GrantAllocation(grantModification);

                grantAllocation.GrantAllocationName = grantAllocationName;
                return(grantAllocation);
            }
Exemplo n.º 3
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());
        }
Exemplo n.º 4
0
            public static ProjectGrantAllocationExpenditure Create(Project project, GrantAllocation grantAllocation, int calendarYear, decimal expenditureAmount)
            {
                var projectGrantAllocationExpenditure = Create(project, grantAllocation, calendarYear);

                projectGrantAllocationExpenditure.ExpenditureAmount = expenditureAmount;
                return(projectGrantAllocationExpenditure);
            }
Exemplo n.º 5
0
            public static ProjectGrantAllocationExpenditure Create(Project project, GrantAllocation grantAllocation, int calendarYear)
            {
                var projectGrantAllocationExpenditure = Create(project, grantAllocation);

                projectGrantAllocationExpenditure.CalendarYear = calendarYear;
                return(projectGrantAllocationExpenditure);
            }
Exemplo n.º 6
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)));
        }
Exemplo n.º 7
0
            public static GrantAllocation CreateWithoutChangingName(string grantAllocationName)
            {
                var grantModification = TestGrantModification.Create();
                var grantAllocation   = new GrantAllocation(grantModification);

                grantAllocation.GrantAllocationName = grantAllocationName;
                return(grantAllocation);
            }
Exemplo n.º 8
0
            public static GrantAllocation CreateWithoutChangingName(string grantAllocationName, Organization organization)
            {
                var grantModification = TestGrantModification.Create();
                var grantAllocation   = new GrantAllocation(grantModification);

                grantAllocation.GrantAllocationName = grantAllocationName;
                grantAllocation.Organization        = organization;
                grantAllocation.OrganizationID      = organization.OrganizationID;
                return(grantAllocation);
            }
Exemplo n.º 9
0
 public GrantAllocationSimple(GrantAllocation grantAllocation)
 {
     this.GrantAllocationID = grantAllocation.GrantAllocationID;
     OrganizationID         = grantAllocation.BottommostOrganization.OrganizationID;
     OrganizationName       = grantAllocation.BottommostOrganization.OrganizationShortNameIfAvailable;
     GrantAllocationName    = grantAllocation.GrantAllocationName;
     IsActive    = true;
     DisplayName = grantAllocation.GrantNumberAndGrantAllocationDisplayName;
     DisplayNameWithAllocationAmount = grantAllocation.GrantNumberAndGrantAllocationWithAllocationAmountDisplay;
 }
Exemplo n.º 10
0
            public static GrantAllocation Create(DatabaseEntities dbContext)
            {
                var    grantModification       = TestFramework.TestGrantModification.Insert(dbContext);
                string testGrantAllocationName = TestFramework.MakeTestName("Test Grant Allocation Name");
                var    grantAllocation         = new GrantAllocation(grantModification);

                grantAllocation.GrantAllocationName = testGrantAllocationName;

                dbContext.GrantAllocations.Add(grantAllocation);
                return(grantAllocation);
            }
        public static List <GrantAllocationApiJson> MakeGrantAllocationApiJsonsFromGrantAllocations(
            List <GrantAllocation> grantAllocations, bool doAlphaSort = true)
        {
            var outgoingGrantAllocations = grantAllocations;

            if (doAlphaSort)
            {
                // This sort order is semi-important; we are highlighting properly constructed, year prefixed Grant Numbers and pushing everything else to the bottom.
                outgoingGrantAllocations = GrantAllocation.OrderGrantAllocationsByYearPrefixedGrantNumbersThenEverythingElse(grantAllocations);
            }
            return(outgoingGrantAllocations.Select(ga => new GrantAllocationApiJson(ga)).ToList());
        }
Exemplo n.º 12
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));
        }
 public GrantAllocationApiJson(GrantAllocation grantAllocation)
 {
     GrantAllocationID              = grantAllocation.GrantAllocationID;
     GrantAllocationName            = grantAllocation.GrantAllocationName;
     GrantID                        = grantAllocation.GrantModification.GrantID;
     StartDate                      = grantAllocation.StartDate;
     EndDate                        = grantAllocation.EndDate;
     AllocationAmount               = grantAllocation.AllocationAmount;
     FederalFundCodeID              = grantAllocation.FederalFundCodeID;
     FederalFundCodeName            = grantAllocation.FederalFundCodeDisplay;
     OrganizationID                 = grantAllocation.OrganizationID;
     OrganizationName               = grantAllocation.Organization?.OrganizationName;
     RegionID                       = grantAllocation.DNRUplandRegionID;
     RegionName                     = grantAllocation.RegionNameDisplay;
     DivisionID                     = grantAllocation.DivisionID;
     DivisionName                   = grantAllocation.Division != null ? grantAllocation.Division.DivisionDisplayName : null;
     GrantManagerID                 = grantAllocation.GrantManagerID;
     GrantManagerName               = grantAllocation.GrantManager?.FullNameFirstLastAndOrgShortName;
     GrantAllocationFileResourceIDs = grantAllocation.GrantAllocationFileResources?.Select(x => x.FileResourceID).ToList();
 }
Exemplo n.º 14
0
            public static ProjectGrantAllocationExpenditure Create(Project project, GrantAllocation grantAllocation)
            {
                var projectGrantAllocationExpenditure = ProjectGrantAllocationExpenditure.CreateNewBlank(project, grantAllocation);

                return(projectGrantAllocationExpenditure);
            }
            public static ProjectGrantAllocationExpenditureUpdate Create(ProjectUpdateBatch projectUpdateBatch, GrantAllocation grantAllocation, int calendarYear, decimal expenditureAmount)
            {
                var projectGrantAllocationExpenditureUpdate = new ProjectGrantAllocationExpenditureUpdate(projectUpdateBatch, calendarYear, expenditureAmount, grantAllocation);

                return(projectGrantAllocationExpenditureUpdate);
            }