public OrganizationAccomplishmentsViewData(List <PerformanceMeasureChartViewData> performanceMeasureChartViewDatas, TaxonomyTier taxonomyTier, TaxonomyLevel associatePerformanceMeasureTaxonomyLevel)
        {
            PerformanceMeasureChartViewDatas = performanceMeasureChartViewDatas;
            TaxonomyTier            = taxonomyTier;
            TaxonomyTierDisplayName = associatePerformanceMeasureTaxonomyLevel.GetFieldDefinition().GetFieldDefinitionLabel();
            var fieldDefinitionForPerformanceMeasure = FieldDefinitionEnum.PerformanceMeasure;

            PerformanceMeasureDisplayName           = fieldDefinitionForPerformanceMeasure.ToType().GetFieldDefinitionLabel();
            PerformanceMeasureDisplayNamePluralized = fieldDefinitionForPerformanceMeasure.ToType().GetFieldDefinitionLabelPluralized();
            OrganizationDisplayName = FieldDefinitionEnum.Organization.ToType().GetFieldDefinitionLabel();
        }
 public ProjectTaxonomyViewData(ProjectFirmaModels.Models.TaxonomyTrunk taxonomyTrunk, TaxonomyLevel taxonomyLevel) : this(taxonomyTrunk, null, null, null, taxonomyLevel)
 {
 }
Example #3
0
        public ActionResult EditBasics(EditBasicsViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                return(ViewEditBasics(viewModel));
            }

            var tenantAttribute = HttpRequestStorage.DatabaseEntities.AllTenantAttributes.Single(a => a.TenantID == viewModel.TenantID);
            var oldTenantAttributeTaxonomyLevel = tenantAttribute.TaxonomyLevel;
            var oldTenantAttributeAssociatePerformanceMeasureTaxonomyLevel = tenantAttribute.AssociatePerfomanceMeasureTaxonomyLevel;

            viewModel.UpdateModel(tenantAttribute, CurrentFirmaSession);
            if (viewModel.BudgetTypeID == BudgetType.AnnualBudgetByCostType.BudgetTypeID)
            {
                var existingCostTypes = HttpRequestStorage.DatabaseEntities.CostTypes.ToList();
                var allCostTypes      = HttpRequestStorage.DatabaseEntities.AllCostTypes.Local;

                viewModel.UpdateCostTypes(existingCostTypes, allCostTypes);
            }
            var clearOutTaxonomyLeafPerformanceMeasures = oldTenantAttributeTaxonomyLevel.TaxonomyLevelID != viewModel.TaxonomyLevelID.Value || oldTenantAttributeAssociatePerformanceMeasureTaxonomyLevel.TaxonomyLevelID != viewModel.AssociatePerfomanceMeasureTaxonomyLevelID.Value;

            if (clearOutTaxonomyLeafPerformanceMeasures)
            {
                var taxonomyLeafPerformanceMeasures = HttpRequestStorage.DatabaseEntities.TaxonomyLeafPerformanceMeasures.ToList();
                foreach (var taxonomyLeafPerformanceMeasure in taxonomyLeafPerformanceMeasures)
                {
                    taxonomyLeafPerformanceMeasure.DeleteFull(HttpRequestStorage.DatabaseEntities);
                }
            }

            // if we are shrinking the number of tiers, we need to collapse child records to hidden parent record(s) named "Default"
            if (oldTenantAttributeTaxonomyLevel.TaxonomyLevelID > viewModel.TaxonomyLevelID.Value)
            {
                var          newTaxonomyLevel         = TaxonomyLevel.ToType(viewModel.TaxonomyLevelID.Value);
                const string defaultTrunkOrBranchName = "Default";
                if (newTaxonomyLevel == TaxonomyLevel.Branch)
                {
                    // create a new "Default" trunk to move all branches to
                    // ensure that name does not already exist
                    var newTaxonomyTrunkDefault = HttpRequestStorage.DatabaseEntities.TaxonomyTrunks.SingleOrDefault(x =>
                                                                                                                     x.TaxonomyTrunkName == defaultTrunkOrBranchName) ?? new TaxonomyTrunk(defaultTrunkOrBranchName);

                    var taxonomyBranches = HttpRequestStorage.DatabaseEntities.TaxonomyBranches.ToList();
                    foreach (var taxonomyBranch in taxonomyBranches)
                    {
                        taxonomyBranch.TaxonomyTrunk = newTaxonomyTrunkDefault;
                    }
                    HttpRequestStorage.DatabaseEntities.SaveChanges();
                    var taxonomyTrunks = HttpRequestStorage.DatabaseEntities.TaxonomyTrunks.Where(x => x.TaxonomyTrunkID != newTaxonomyTrunkDefault.TaxonomyTrunkID).ToList();
                    foreach (var taxonomyTrunk in taxonomyTrunks)
                    {
                        taxonomyTrunk.DeleteFull(HttpRequestStorage.DatabaseEntities);
                    }
                }
                else if (newTaxonomyLevel == TaxonomyLevel.Leaf)
                {
                    var newTaxonomyTrunkDefault = HttpRequestStorage.DatabaseEntities.TaxonomyTrunks.SingleOrDefault(x =>
                                                                                                                     x.TaxonomyTrunkName == defaultTrunkOrBranchName) ?? new TaxonomyTrunk(defaultTrunkOrBranchName);
                    var newTaxonomyBranchDefault = HttpRequestStorage.DatabaseEntities.TaxonomyBranches.SingleOrDefault(x =>
                                                                                                                        x.TaxonomyBranchName == defaultTrunkOrBranchName) ?? new TaxonomyBranch(newTaxonomyTrunkDefault, defaultTrunkOrBranchName);
                    var taxonomyLeaves = HttpRequestStorage.DatabaseEntities.TaxonomyLeafs.ToList();
                    foreach (var taxonomyLeaf in taxonomyLeaves)
                    {
                        taxonomyLeaf.TaxonomyBranch = newTaxonomyBranchDefault;
                    }
                    HttpRequestStorage.DatabaseEntities.SaveChanges();
                    var taxonomyBranches = HttpRequestStorage.DatabaseEntities.TaxonomyBranches.Where(x => x.TaxonomyBranchID != newTaxonomyBranchDefault.TaxonomyBranchID).ToList();
                    foreach (var taxonomyBranch in taxonomyBranches)
                    {
                        taxonomyBranch.DeleteFull(HttpRequestStorage.DatabaseEntities);
                    }

                    var taxonomyTrunks = HttpRequestStorage.DatabaseEntities.TaxonomyTrunks.Where(x => x.TaxonomyTrunkID != newTaxonomyTrunkDefault.TaxonomyTrunkID).ToList();
                    foreach (var taxonomyTrunk in taxonomyTrunks)
                    {
                        taxonomyTrunk.DeleteFull(HttpRequestStorage.DatabaseEntities);
                    }
                }
            }

            MultiTenantHelpers.ClearTenantAttributeCacheForAllTenants();

            return(new ModalDialogFormJsonResult(new SitkaRoute <TenantController>(c => c.Detail()).BuildUrlFromExpression()));
        }
 public EditViewData(PerformanceMeasureSimple performanceMeasure, List <TaxonomyTier> taxonomyTiers, TaxonomyLevel associatePerformanceMeasureTaxonomyLevel)
 {
     PerformanceMeasure                = performanceMeasure;
     AllTaxonomyTiers                  = taxonomyTiers;
     FieldDefinitionForTaxonomyTier    = associatePerformanceMeasureTaxonomyLevel.GetFieldDefinition();
     TaxonomyTierDisplayName           = FieldDefinitionForTaxonomyTier.GetFieldDefinitionLabel();
     TaxonomyTierDisplayNamePluralized = FieldDefinitionForTaxonomyTier.GetFieldDefinitionLabelPluralized();
 }
 public ProjectTaxonomyViewData(Models.Project project, TaxonomyLevel taxonomyLevel) : this(project.ProjectType.TaxonomyBranch.TaxonomyTrunk, project.ProjectType.TaxonomyBranch, project.ProjectType, project, taxonomyLevel)
 {
 }
 private ProjectTaxonomyViewData(Models.TaxonomyTrunk taxonomyTrunk, Models.TaxonomyBranch taxonomyBranch, Models.ProjectType projectType, Models.Project project, TaxonomyLevel taxonomyLevel)
 {
     ProjectType      = projectType;
     TaxonomyTrunk    = taxonomyTrunk;
     TaxonomyBranch   = taxonomyBranch;
     Project          = project;
     IsProject        = Project != null;
     IsProjectType    = ProjectType != null && !IsProject;
     IsTaxonomyBranch = TaxonomyBranch != null && !IsProjectType && !IsProject;
     IsTaxonomyTrunk  = TaxonomyTrunk != null && !IsTaxonomyBranch && !IsProjectType && !IsProject;
     TaxonomyLevel    = taxonomyLevel;
 }
 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();
 }
 public ProjectTaxonomyViewData(Models.TaxonomyBranch taxonomyBranch, TaxonomyLevel taxonomyLevel) : this(taxonomyBranch.TaxonomyTrunk, taxonomyBranch, null, null, taxonomyLevel)
 {
 }
Example #9
0
 public ProjectBasicsViewData(Models.Project project, bool userHasProjectBudgetManagePermissions, TaxonomyLevel taxonomyLevel)
 {
     Project = project;
     UserHasProjectBudgetManagePermissions = userHasProjectBudgetManagePermissions;
     ProjectTaxonomyViewData = new ProjectTaxonomyViewData(project, taxonomyLevel);
 }
Example #10
0
        public DetailViewData(FirmaSession currentFirmaSession,
                              ProjectFirmaModels.Models.TaxonomyLeaf taxonomyLeaf,
                              ProjectLocationsMapInitJson primaryProjectLocationsMapInitJson,
                              ProjectLocationsMapInitJson secondaryProjectLocationsMapInitJson,
                              ProjectLocationsMapViewData primaryProjectLocationsMapViewData,
                              ProjectLocationsMapViewData secondaryProjectLocationsMapViewData,
                              bool canHaveAssociatedPerformanceMeasures,
                              RelatedPerformanceMeasuresViewData relatedPerformanceMeasuresViewData,
                              TaxonomyLevel taxonomyLevel,
                              TenantAttribute tenantAttribute,
                              IEnumerable <ProjectFirmaModels.Models.PerformanceMeasure> performanceMeasures,
                              Dictionary <int, PerformanceMeasureChartViewData> primaryPerformanceMeasureChartViewDataByPerformanceMeasure,
                              Dictionary <int, PerformanceMeasureChartViewData> secondaryPerformanceMeasureChartViewDataByPerformanceMeasure,
                              List <ProjectCustomGridConfiguration> projectCustomDefaultGridConfigurations) : base(currentFirmaSession)
        {
            TaxonomyLeaf = taxonomyLeaf;
            PageTitle    = taxonomyLeaf.GetDisplayName();
            var fieldDefinitionTaxonomyLeaf = FieldDefinitionEnum.TaxonomyLeaf;
            var taxonomyLeafDisplayName     = fieldDefinitionTaxonomyLeaf.ToType().GetFieldDefinitionLabel();

            EntityName = taxonomyLeafDisplayName;

            PrimaryProjectLocationsMapInitJson   = primaryProjectLocationsMapInitJson;
            PrimaryProjectLocationsMapViewData   = primaryProjectLocationsMapViewData;
            SecondaryProjectLocationsMapInitJson = secondaryProjectLocationsMapInitJson;
            SecondaryProjectLocationsMapViewData = secondaryProjectLocationsMapViewData;
            ProjectMapFilteredUrl = PrimaryProjectLocationsMapInitJson.ProjectMapCustomization.GetCustomizedUrl();

            UserHasTaxonomyLeafManagePermissions = new TaxonomyLeafManageFeature().HasPermissionByFirmaSession(currentFirmaSession);
            EditTaxonomyLeafUrl = SitkaRoute <TaxonomyLeafController> .BuildUrlFromExpression(c => c.Edit(taxonomyLeaf));

            IndexUrl = SitkaRoute <ProgramInfoController> .BuildUrlFromExpression(x => x.Taxonomy());

            SecondaryBasicProjectInfoGridName = "secondaryLeafProjectListGrid";
            BasicProjectInfoGridSpec          = new ProjectForTaxonomyLeafGridSpec(currentFirmaSession, true, taxonomyLeaf)
            {
                ObjectNameSingular  = $"{FieldDefinitionEnum.Project.ToType().GetFieldDefinitionLabel()} with this {taxonomyLeafDisplayName}",
                ObjectNamePlural    = $"{FieldDefinitionEnum.Project.ToType().GetFieldDefinitionLabelPluralized()} with this {taxonomyLeafDisplayName}",
                SaveFiltersInCookie = true
            };

            SecondaryBasicProjectInfoGridDataUrl = SitkaRoute <TaxonomyLeafController> .BuildUrlFromExpression(tc => tc.SecondaryProjectsGridJsonData(taxonomyLeaf));

            ProjectTaxonomyViewData = new ProjectTaxonomyViewData(taxonomyLeaf, taxonomyLevel);

            var projectDetails = HttpRequestStorage.DatabaseEntities.vProjectDetails.ToDictionary(x => x.ProjectID);

            ProjectCustomDefaultGridSpec = new ProjectCustomGridSpec(currentFirmaSession, projectCustomDefaultGridConfigurations, ProjectCustomGridType.Default.ToEnum, projectDetails, currentFirmaSession.Tenant)
            {
                ObjectNameSingular = $"{FieldDefinitionEnum.Project.ToType().GetFieldDefinitionLabel()}", ObjectNamePlural = $"{FieldDefinitionEnum.Project.ToType().GetFieldDefinitionLabelPluralized()}", SaveFiltersInCookie = true
            };

            ProjectCustomDefaultGridName    = "taxonomyLeafProjectListGrid";
            ProjectCustomDefaultGridDataUrl = SitkaRoute <ProjectCustomGridController> .BuildUrlFromExpression(tc => tc.TaxonomyLeafProjectsGridJsonData(taxonomyLeaf));

            TaxonomyLeafDisplayName           = taxonomyLeafDisplayName;
            TaxonomyLeafDisplayNamePluralized = fieldDefinitionTaxonomyLeaf.ToType().GetFieldDefinitionLabelPluralized();

            CanHaveAssociatedPerformanceMeasures = canHaveAssociatedPerformanceMeasures;
            PerformanceMeasures = performanceMeasures;
            PrimaryPerformanceMeasureChartViewDataByPerformanceMeasure   = primaryPerformanceMeasureChartViewDataByPerformanceMeasure;
            SecondaryPerformanceMeasureChartViewDataByPerformanceMeasure = secondaryPerformanceMeasureChartViewDataByPerformanceMeasure;
            RelatedPerformanceMeasuresViewData = relatedPerformanceMeasuresViewData;

            TenantAttribute = tenantAttribute;
        }
Example #11
0
 public AddProjectEvaluationViewDataForAngular(List <TaxonomyTierSimple> taxonomyTrunkSimples, List <TaxonomyTierSimple> taxonomyBranchSimples, List <TaxonomyTierSimple> taxonomyLeafSimples, List <ProjectSimple> projectSimples, TaxonomyLevel taxonomyLevel, List <ProjectStageSimple> projectStageSimples)
 {
     TaxonomyTrunkSimples  = taxonomyTrunkSimples;
     TaxonomyBranchSimples = taxonomyBranchSimples;
     TaxonomyLeafSimples   = taxonomyLeafSimples;
     ProjectSimples        = projectSimples;
     TaxonomyLevel         = taxonomyLevel.TaxonomyLevelID;
     ProjectStageSimples   = projectStageSimples;
 }
        public DetailViewData(Person currentPerson,
                              Models.ProjectType projectType,
                              ProjectLocationsMapInitJson projectLocationsMapInitJson,
                              ProjectLocationsMapViewData projectLocationsMapViewData, bool canHaveAssociatedPerformanceMeasures,
                              RelatedPerformanceMeasuresViewData relatedPerformanceMeasuresViewData,
                              List <PerformanceMeasureChartViewData> performanceMeasureChartViewDatas, TaxonomyLevel taxonomyLevel) : base(currentPerson)
        {
            ProjectType = projectType;
            PageTitle   = projectType.DisplayName;
            var fieldDefinitionProjectType = Models.FieldDefinition.ProjectType;
            var projectTypeDisplayName     = fieldDefinitionProjectType.GetFieldDefinitionLabel();

            EntityName = projectTypeDisplayName;

            ProjectLocationsMapInitJson = projectLocationsMapInitJson;
            ProjectLocationsMapViewData = projectLocationsMapViewData;
            ProjectMapFilteredUrl       = ProjectLocationsMapInitJson.ProjectMapCustomization.GetCustomizedUrl();

            UserHasProjectTypeManagePermissions = new ProjectTypeManageFeature().HasPermissionByPerson(CurrentPerson);
            EditProjectTypeUrl = SitkaRoute <ProjectTypeController> .BuildUrlFromExpression(c => c.Edit(projectType));

            IndexUrl = SitkaRoute <ProgramInfoController> .BuildUrlFromExpression(x => x.Taxonomy());

            BasicProjectInfoGridName = "projectTypeProjectListGrid";
            BasicProjectInfoGridSpec = new BasicProjectInfoGridSpec(CurrentPerson, true)
            {
                ObjectNameSingular  = $"{Models.FieldDefinition.Project.GetFieldDefinitionLabel()} with this {projectTypeDisplayName}",
                ObjectNamePlural    = $"{Models.FieldDefinition.Project.GetFieldDefinitionLabelPluralized()} with this {projectTypeDisplayName}",
                SaveFiltersInCookie = true
            };

            BasicProjectInfoGridDataUrl = SitkaRoute <ProjectTypeController> .BuildUrlFromExpression(tc => tc.ProjectsGridJsonData(projectType));

            ProjectTaxonomyViewData = new ProjectTaxonomyViewData(projectType, taxonomyLevel);

            ProjectTypeDisplayName           = projectTypeDisplayName;
            ProjectTypeDisplayNamePluralized = fieldDefinitionProjectType.GetFieldDefinitionLabelPluralized();

            CanHaveAssociatedPerformanceMeasures = canHaveAssociatedPerformanceMeasures;
            PerformanceMeasureChartViewDatas     = performanceMeasureChartViewDatas;
            RelatedPerformanceMeasuresViewData   = relatedPerformanceMeasuresViewData;
        }
        public RelatedTaxonomyTiersViewData(ProjectFirmaModels.Models.PerformanceMeasure performanceMeasure, TaxonomyLevel associatePerformanceMeasureTaxonomyLevel, bool showHelpLinks)
        {
            TaxonomyLeafPerformanceMeasures = performanceMeasure.GetTaxonomyTiers();
            PerformanceMeasureDisplayName   = MultiTenantHelpers.GetPerformanceMeasureName();
            var fieldDefinitionForTaxonomyTier = associatePerformanceMeasureTaxonomyLevel.GetFieldDefinition();

            TaxonomyTierDisplayName       = fieldDefinitionForTaxonomyTier.GetFieldDefinitionLabel();
            TaxonomyTierHeaderDisplayName = showHelpLinks
                ? LabelWithSugarForExtensions.LabelWithSugarFor(
                fieldDefinitionForTaxonomyTier,
                LabelWithSugarForExtensions.DisplayStyle.HelpIconWithLabel, TaxonomyTierDisplayName)
                : new HtmlString(TaxonomyTierDisplayName);
            TaxonomyTierDisplayNamePluralized        = fieldDefinitionForTaxonomyTier.GetFieldDefinitionLabelPluralized();
            AssociatePerformanceMeasureTaxonomyLevel = associatePerformanceMeasureTaxonomyLevel;
        }