Esempio n. 1
0
        public GrantAllocationBudgetLineItemGridSpec(Models.Person currentPerson, Models.GrantAllocation grantAllocation)
        {
            ObjectNameSingular  = $"{Models.FieldDefinition.GrantAllocationBudgetLineItem.GetFieldDefinitionLabel()}";
            ObjectNamePlural    = $"{Models.FieldDefinition.GrantAllocationBudgetLineItem.GetFieldDefinitionLabelPluralized()}";
            SaveFiltersInCookie = true;


            var userHasEditPermissions = new GrantAllocationBudgetLineItemEditAsAdminFeature().HasPermissionByPerson(currentPerson);

            if (userHasEditPermissions)
            {
                Add(string.Empty, x => DhtmlxGridHtmlHelpers.MakeEditIconAsModalDialogLinkBootstrap(new ModalDialogForm(x.GetEditGrantAllocationBudgetLineItemUrl(), $"Edit this {Models.FieldDefinition.GrantAllocationBudgetLineItem.GetFieldDefinitionLabel()}")), 30, DhtmlxGridColumnFilterType.None);

                var createNewGrantAllocationBudgetLineItemUrl = SitkaRoute <GrantAllocationController> .BuildUrlFromExpression(t => t.NewGrantAllocationBudgetLineItem(grantAllocation.PrimaryKey));

                CreateEntityModalDialogForm = new ModalDialogForm(createNewGrantAllocationBudgetLineItemUrl, $"Create a new {Models.FieldDefinition.GrantAllocationBudgetLineItem.GetFieldDefinitionLabel()}");
            }

            var userHasDeletePermissions = new GrantAllocationBudgetLineItemDeleteAsAdminFeature().HasPermissionByPerson(currentPerson);

            if (userHasDeletePermissions)
            {
                Add(string.Empty, x => DhtmlxGridHtmlHelpers.MakeDeleteIconAndLinkBootstrap(x.GetDeleteGrantAllocationBudgetLineItemUrl(), true, true), 30, DhtmlxGridColumnFilterType.None);
            }

            Add("Cost Type", x => x.CostType.CostTypeDisplayName, 125, DhtmlxGridColumnFilterType.Text);
            Add("Amount", x => x.GrantAllocationBudgetLineItemAmount, 125, DhtmlxGridColumnFormatType.CurrencyWithCents, DhtmlxGridColumnAggregationType.Total);
            Add("Note", x => x.GrantAllocationBudgetLineItemNote, 650, DhtmlxGridColumnFilterType.Text);
        }
 public GrantAllocationBasicsViewData(Models.GrantAllocation grantAllocation, bool userHasGrantAllocationManagePermissions, TaxonomyLevel taxonomyLevel)
 {
     GrantAllocation = grantAllocation;
     UserHasGrantAllocationManagePermissions = userHasGrantAllocationManagePermissions;
     // Used for creating file download links, if files available
     ShowDownload = grantAllocation.GrantAllocationFileResources.Any();
 }
Esempio n. 3
0
 public GrantAllocationRequestAmount(Models.GrantAllocation grantAllocation, decimal?totalAmount, decimal?matchAmount, decimal?payAmount, string displayCssClass)
 {
     GrantAllocation = grantAllocation;
     TotalAmount     = totalAmount;
     DisplayCssClass = displayCssClass;
     MatchAmount     = matchAmount;
     PayAmount       = payAmount;
 }
Esempio n. 4
0
        protected GrantAllocationViewData(Person currentPerson, Models.GrantAllocation grantAllocation) : base(currentPerson, null)
        {
            GrantAllocation        = grantAllocation;
            HtmlPageTitle          = grantAllocation.GrantAllocationName;
            EntityName             = $"{Models.FieldDefinition.GrantAllocation.GetFieldDefinitionLabel()}";
            EditGrantAllocationUrl = grantAllocation.GetEditUrl();

            UserHasEditGrantAllocationPermissions = new GrantAllocationEditAsAdminFeature().HasPermissionByPerson(currentPerson);
            BackToGrantAllocationsText            = "Back to all Grant Allocations";
            GrantAllocationsListUrl = SitkaRoute <GrantController> .BuildUrlFromExpression(c => c.Index());
        }
Esempio n. 5
0
        public DetailViewData(Person currentPerson, Models.GrantAllocation grantAllocation
                              , GrantAllocationBasicsViewData grantAllocationBasicsViewData
                              , EntityNotesViewData grantAllocationNotesViewData
                              , EntityNotesViewData grantAllocationNoteInternalsViewData
                              , ViewGoogleChartViewData viewGoogleChartViewData
                              , GridSpec <Models.ProjectGrantAllocationRequest> projectGrantAllocationRequestsGridSpec
                              , GrantAllocationExpendituresGridSpec grantAllocationExpendituresGridSpec)
            : base(currentPerson, grantAllocation)
        {
            PageTitle       = grantAllocation.GrantAllocationName.ToEllipsifiedStringClean(110);
            BreadCrumbTitle = $"{Models.FieldDefinition.GrantAllocation.GetFieldDefinitionLabel()} Detail";

            GrantAllocationBasicsViewData = grantAllocationBasicsViewData;
            GrantAllocationNotesViewData  = grantAllocationNotesViewData;

            NewGrantAllocationNoteUrl            = grantAllocation.GetNewNoteUrl();
            GrantAllocationNoteInternalsViewData = grantAllocationNoteInternalsViewData;

            ViewGoogleChartViewData = viewGoogleChartViewData;

            var projectGrantAllocationExpenditures = GrantAllocation.ProjectGrantAllocationExpenditures.ToList();

            CalendarYearsForProjectExpenditures = projectGrantAllocationExpenditures.CalculateCalendarYearRangeForExpenditures(grantAllocation);

            ProjectCalendarYearExpendituresGridSpec = new ProjectCalendarYearExpendituresGridSpec(CalendarYearsForProjectExpenditures)
            {
                ObjectNameSingular  = $"{Models.FieldDefinition.Project.GetFieldDefinitionLabel()}",
                ObjectNamePlural    = $"{Models.FieldDefinition.Project.GetFieldDefinitionLabelPluralized()}",
                SaveFiltersInCookie = true
            };

            ProjectCalendarYearExpendituresGridName    = "projectsCalendarYearExpendituresFromGrantAllocationGrid";
            ProjectCalendarYearExpendituresGridDataUrl = SitkaRoute <GrantAllocationController> .BuildUrlFromExpression(tc => tc.ProjectCalendarYearExpendituresGridJsonData(grantAllocation));

            ProjectGrantAllocationRequestsGridSpec    = projectGrantAllocationRequestsGridSpec;
            ProjectGrantAllocationRequestsGridName    = "projectsGrantAllocationRequestsFromGrantAllocationGrid";
            ProjectGrantAllocationRequestsGridDataUrl = SitkaRoute <GrantAllocationController> .BuildUrlFromExpression(tc => tc.ProjectGrantAllocationRequestsGridJsonData(grantAllocation));

            GrantAllocationExpendituresGridSpec    = grantAllocationExpendituresGridSpec;
            GrantAllocationExpendituresGridName    = "grantAllocationExpendituresGrid";
            GrantAllocationExpendituresGridDataUrl = SitkaRoute <GrantAllocationController> .BuildUrlFromExpression(gac => gac.GrantAllocationExpendituresGridJsonData(grantAllocation));

            GrantAllocationBudgetLineItemsViewData = new GrantAllocationBudgetLineItemsViewData(currentPerson, grantAllocation, grantAllocation.GrantAllocationBudgetLineItems.ToList());
            GrantAllocationBudgetVsActualsViewData = new GrantAllocationBudgetVsActualsViewData(currentPerson, grantAllocation);

            var canEditDocuments = new GrantAllocationEditAsAdminFeature().HasPermission(currentPerson, grantAllocation).HasPermission;

            GrantAllocationDetailsFileDetailsViewData = new FileDetailsViewData(
                EntityDocument.CreateFromEntityDocument(new List <IEntityDocument>(grantAllocation.GrantAllocationFileResources)),
                SitkaRoute <GrantAllocationController> .BuildUrlFromExpression(x => x.NewGrantAllocationFiles(grantAllocation.PrimaryKey)),
                canEditDocuments,
                Models.FieldDefinition.GrantAllocation
                );
        }
Esempio n. 6
0
        public GrantAllocationAwardGridSpec(Person currentPerson, Models.GrantAllocation grantAllocation)
            : this(currentPerson)
        {
            ObjectNameSingular = $"{Models.FieldDefinition.GrantAllocationAward.GetFieldDefinitionLabel()}";
            ObjectNamePlural   = $"{Models.FieldDefinition.GrantAllocationAward.GetFieldDefinitionLabelPluralized()} associated with {grantAllocation.DisplayName}";

            var userHasCreatePermissions = new GrantAllocationAwardCreateFeature().HasPermissionByPerson(currentPerson);
            if (userHasCreatePermissions && grantAllocation.DNRUplandRegionID.HasValue)
            {
                var contentUrl = SitkaRoute <GrantAllocationAwardController> .BuildUrlFromExpression(t => t.NewForAGrantAllocation(grantAllocation));

                CreateEntityModalDialogForm = new ModalDialogForm(contentUrl, 950, $"Create a new {ObjectNameSingular}");
            }
        }
Esempio n. 7
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));
            }
        }
Esempio n. 8
0
        public EditGrantAllocationViewData(EditGrantAllocationType editGrantAllocationType,
                                           Models.GrantAllocation grantAllocationBeingEdited,
                                           IEnumerable <ProjectFirma.Web.Models.Organization> organizations,
                                           IEnumerable <GrantType> grantTypes,
                                           List <ProjectFirma.Web.Models.Grant> grants,
                                           List <Models.GrantModification> grantModifications,
                                           IEnumerable <Division> divisions,
                                           IEnumerable <Models.DNRUplandRegion> dnrUplandRegions,
                                           IEnumerable <FederalFundCode> federalFundCodes,
                                           List <Person> allPeople)
        {
            Organizations      = organizations.ToSelectListWithEmptyFirstRow(x => x.OrganizationID.ToString(CultureInfo.InvariantCulture), y => y.DisplayName);//sorted in the controller
            GrantTypes         = grantTypes.ToSelectListWithEmptyFirstRow(x => x.GrantTypeID.ToString(CultureInfo.InvariantCulture), y => y.GrantTypeName);
            GrantNumbers       = grants.OrderBy(x => x.GrantNumber).ToSelectList(x => x.GrantID.ToString(CultureInfo.InvariantCulture), y => y.GrantNumber);
            Divisions          = divisions.OrderBy(x => x.DivisionDisplayName).ToSelectListWithEmptyFirstRow(x => x.DivisionID.ToString(CultureInfo.InvariantCulture), y => y.DivisionDisplayName);
            Regions            = dnrUplandRegions.OrderBy(x => x.DNRUplandRegionName).ToSelectListWithEmptyFirstRow(x => x.DNRUplandRegionID.ToString(CultureInfo.InvariantCulture), y => y.DNRUplandRegionName);
            GrantModifications = grantModifications.OrderByDescending(x => x.GrantModificationNameForDisplay).ToSelectListWithEmptyFirstRow(x => x.GrantModificationID.ToString(CultureInfo.InvariantCulture), y => y.GrantModificationNameForDisplay);
            AngularViewData    = new EditGrantAllocationAngularViewData(grantModifications);

            FederalFundCodes = federalFundCodes.OrderBy(x => x.FederalFundCodeAbbrev).ToSelectListWithEmptyFirstRow(
                x => x.FederalFundCodeID.ToString(CultureInfo.InvariantCulture), y => y.FederalFundCodeAbbrev);
            GrantManagers = allPeople.OrderBy(x => x.FullNameLastFirst)
                            .ToSelectListWithEmptyFirstRow(x => x.PersonID.ToString(CultureInfo.InvariantCulture),
                                                           y => y.FullNameFirstLastAndOrgShortName);

            // Include Persons who currently have the right a Program Manager
            List <Person> peopleWhoAreProgramManagers = allPeople.Where(x => x.IsProgramManager == true).ToList();

            // Include anyone who was set to be a Program Manager for this GrantAllocation in the past, but who may no longer have the right on their Person record.
            if (grantAllocationBeingEdited != null)
            {
                peopleWhoAreProgramManagers.AddRange(grantAllocationBeingEdited.GrantAllocationProgramManagers.Select(pm => pm.Person));
            }
            peopleWhoAreProgramManagers = peopleWhoAreProgramManagers.Distinct().ToList();

            ProgramManagersSelectList = peopleWhoAreProgramManagers.OrderBy(x => x.FullNameLastFirst)
                                        .ToSelectList(x => x.PersonID.ToString(CultureInfo.InvariantCulture),
                                                      y => y.FullNameFirstLastAndOrgShortName);

            EditGrantAllocationType = editGrantAllocationType;
            AddContactUrl           = SitkaRoute <UserController> .BuildUrlFromExpression(x => x.Index());
        }
Esempio n. 9
0
        public EditGrantAllocationViewModel(Models.GrantAllocation grantAllocation)
        {
            GrantAllocationID   = grantAllocation.GrantAllocationID;
            GrantAllocationName = grantAllocation.GrantAllocationName;
            OrganizationID      = grantAllocation.OrganizationID;
            GrantModificationID = grantAllocation.GrantModificationID;

            ProgramIndexProjectCodeJsons =
                ProgramIndexProjectCodeJson
                .MakeProgramIndexProjectCodeJsonsFromGrantAllocationProgramIndexProjectCodes(grantAllocation.GrantAllocationProgramIndexProjectCodes.ToList());

            FederalFundCodeID       = grantAllocation.FederalFundCodeID;
            DivisionID              = grantAllocation.DivisionID;
            DNRUplandRegionID       = grantAllocation.RegionIDDisplay;
            AllocationAmount        = grantAllocation.AllocationAmount;
            StartDate               = grantAllocation.StartDate;
            EndDate                 = grantAllocation.EndDate;
            ProgramManagerPersonIDs = grantAllocation.ProgramManagerPersonIDs;
            GrantManagerID          = grantAllocation.GrantManagerID;
            //GrantAllocationFileResourceDatas = grantAllocation.GrantAllocationFileResources
        }
Esempio n. 10
0
 public EditGrantAllocationBudgetLineItemViewModel(Models.GrantAllocation grantAllocation)
 {
     GrantAllocationID = grantAllocation.GrantAllocationID;
 }
Esempio n. 11
0
 public GrantAllocationJson(Models.GrantAllocation grantAllocation)
 {
     this.GrantAllocationID   = grantAllocation.GrantAllocationID;
     this.GrantNumber         = grantAllocation.GrantModification.Grant.GrantNumber;
     this.GrantAllocationName = grantAllocation.GrantAllocationName;
 }
Esempio n. 12
0
 public GrantAllocationCalendarYearExpenditure(Models.GrantAllocation grantAllocation, Dictionary <int, decimal?> calendarYearExpenditure, string displayCssClass)
 {
     GrantAllocation         = grantAllocation;
     CalendarYearExpenditure = calendarYearExpenditure;
     DisplayCssClass         = displayCssClass;
 }
Esempio n. 13
0
        public void UpdateModel(Models.GrantAllocation grantAllocation, Person currentPerson)
        {
            grantAllocation.GrantAllocationName = GrantAllocationName;
            grantAllocation.OrganizationID      = OrganizationID;
            //grantAllocation.GrantID = GrantID;

            grantAllocation.FederalFundCodeID = FederalFundCodeID;
            grantAllocation.DivisionID        = DivisionID;
            grantAllocation.DNRUplandRegionID = DNRUplandRegionID;
            if (grantAllocation.AllocationAmount != AllocationAmount)
            {
                GrantAllocationChangeLog newChange = new GrantAllocationChangeLog(
                    grantAllocation,
                    currentPerson,
                    DateTime.Now
                    );
                newChange.GrantAllocationAmountOldValue = grantAllocation.AllocationAmount;
                newChange.GrantAllocationAmountNewValue = AllocationAmount;
                newChange.GrantAllocationAmountNote     = GrantAllocationChangeLogNote;
            }
            grantAllocation.AllocationAmount = AllocationAmount;
            grantAllocation.StartDate        = StartDate;
            grantAllocation.EndDate          = EndDate;
            grantAllocation.GrantManagerID   = GrantManagerID;

            // Who is actually allowed to be a Program Manager for this Grant Allocation?
            List <Person> personsAllowedToBeProgramManager = new List <Person>();

            // Anyone who CURRENTLY has the role can keep it, even if their Person record has lost the permission in the meantime
            personsAllowedToBeProgramManager.AddRange(grantAllocation.GrantAllocationProgramManagers.Select(pm => pm.Person).ToList());
            // Also, anyone who has the right in the database is allowed
            personsAllowedToBeProgramManager.AddRange(HttpRequestStorage.DatabaseEntities.People.ToList().Where(p => p.IsProgramManager == true).ToList());
            personsAllowedToBeProgramManager = personsAllowedToBeProgramManager.Distinct().ToList();

            var personIDsAllowedToBeProgramManager = personsAllowedToBeProgramManager.Select(papm => papm.PersonID).ToList();
            var personIDsNotAllowed = new List <int>();

            if (this.ProgramManagerPersonIDs != null)
            {
                personIDsNotAllowed = this.ProgramManagerPersonIDs.Except(personIDsAllowedToBeProgramManager).ToList();
            }
            Check.Ensure(!personIDsNotAllowed.Any(), $"Found {personIDsNotAllowed.Count} PersonIDs not allowed to be Program Managers attempting to be saved: {string.Join(", ", personIDsNotAllowed)}");

            // Deleting existing records
            grantAllocation.GrantAllocationProgramManagers.ToList().ForEach(gapm => gapm.DeleteFull(HttpRequestStorage.DatabaseEntities));
            grantAllocation.GrantAllocationProgramManagers = this.ProgramManagerPersonIDs != null?this.ProgramManagerPersonIDs.Select(p => new GrantAllocationProgramManager(grantAllocation.GrantAllocationID, p)).ToList() : new List <GrantAllocationProgramManager>();

            if (GrantAllocationFileResourceDatas?[0] != null)
            {
                var fileResources = GrantAllocationFileResourceDatas.Select(fileData =>
                                                                            FileResource.CreateNewFromHttpPostedFile(fileData, currentPerson));

                foreach (var fileResource in fileResources)
                {
                    HttpRequestStorage.DatabaseEntities.FileResources.Add(fileResource);
                    var grantAllocationFileResource = new GrantAllocationFileResource(grantAllocation, fileResource, fileResource.OriginalCompleteFileName);
                    grantAllocation.GrantAllocationFileResources.Add(grantAllocationFileResource);
                }
            }

            //delete existing GrantAllocationProgramIndexProjectCode records
            grantAllocation.GrantAllocationProgramIndexProjectCodes.ToList().ForEach(gapipc => gapipc.DeleteFull(HttpRequestStorage.DatabaseEntities));
            //create new rows of GrantAllocationProgramIndexProjectCode
            grantAllocation.GrantAllocationProgramIndexProjectCodes =
                ProgramIndexProjectCodeJsons.Where(gapipc => gapipc.ProgramIndexID != null).Select(gapipc =>
                                                                                                   new GrantAllocationProgramIndexProjectCode(grantAllocation.GrantAllocationID, (int)gapipc.ProgramIndexID, gapipc.ProjectCodeID)).ToList();
        }
Esempio n. 14
0
 public GrantAllocationBudgetVsActualsViewData(Person currentPerson, Models.GrantAllocation grantAllocation) : base(currentPerson)
 {
     GrantAllocationBudgetVsActualsGridSpec    = new GrantAllocationBudgetVsActualsGridSpec();
     GrantAllocationBudgetVsActualsGridDataUrl = SitkaRoute <GrantAllocationController> .BuildUrlFromExpression(gac => gac.GrantAllocationBudgetVsActualsGridJsonData(grantAllocation));
 }