/// <summary>
 /// Constructor for building a new object with MinimalConstructor required fields, using objects whenever possible
 /// </summary>
 public CostAuthority(TaxonomyLeaf taxonomyLeaf) : this()
 {
     // Mark this as a new object by setting primary key with special value
     this.CostAuthorityID = ModelObjectHelpers.MakeNextUnsavedPrimaryKeyValue();
     this.TaxonomyLeafID  = taxonomyLeaf.TaxonomyLeafID;
     this.TaxonomyLeaf    = taxonomyLeaf;
     taxonomyLeaf.CostAuthorities.Add(this);
 }
Exemple #2
0
 public EditViewModel(ProjectFirmaModels.Models.TaxonomyLeaf taxonomyLeaf)
 {
     TaxonomyLeafID          = taxonomyLeaf.TaxonomyLeafID;
     TaxonomyLeafName        = taxonomyLeaf.TaxonomyLeafName;
     TaxonomyLeafDescription = taxonomyLeaf.TaxonomyLeafDescriptionHtmlString;
     TaxonomyBranchID        = taxonomyLeaf.TaxonomyBranchID;
     ThemeColor = taxonomyLeaf.ThemeColor;
 }
 /// <summary>
 /// Constructor for building a new object with MinimalConstructor required fields, using objects whenever possible
 /// </summary>
 public TaxonomyLeafPerformanceMeasure(TaxonomyLeaf taxonomyLeaf, PerformanceMeasure performanceMeasure) : this()
 {
     // Mark this as a new object by setting primary key with special value
     this.TaxonomyLeafPerformanceMeasureID = ModelObjectHelpers.MakeNextUnsavedPrimaryKeyValue();
     this.TaxonomyLeafID = taxonomyLeaf.TaxonomyLeafID;
     this.TaxonomyLeaf   = taxonomyLeaf;
     taxonomyLeaf.TaxonomyLeafPerformanceMeasures.Add(this);
     this.PerformanceMeasureID = performanceMeasure.PerformanceMeasureID;
     this.PerformanceMeasure   = performanceMeasure;
     performanceMeasure.TaxonomyLeafPerformanceMeasures.Add(this);
 }
Exemple #4
0
 /// <summary>
 /// Constructor for building a new object with MinimalConstructor required fields, using objects whenever possible
 /// </summary>
 public SecondaryProjectTaxonomyLeaf(Project project, TaxonomyLeaf taxonomyLeaf) : this()
 {
     // Mark this as a new object by setting primary key with special value
     this.SecondaryProjectTaxonomyLeafID = ModelObjectHelpers.MakeNextUnsavedPrimaryKeyValue();
     this.ProjectID = project.ProjectID;
     this.Project   = project;
     project.SecondaryProjectTaxonomyLeafs.Add(this);
     this.TaxonomyLeafID = taxonomyLeaf.TaxonomyLeafID;
     this.TaxonomyLeaf   = taxonomyLeaf;
     taxonomyLeaf.SecondaryProjectTaxonomyLeafs.Add(this);
 }
 private ProjectTaxonomyViewData(ProjectFirmaModels.Models.TaxonomyTrunk taxonomyTrunk, ProjectFirmaModels.Models.TaxonomyBranch taxonomyBranch, ProjectFirmaModels.Models.TaxonomyLeaf taxonomyLeaf, ProjectFirmaModels.Models.Project project, TaxonomyLevel taxonomyLevel)
 {
     TaxonomyLeaf     = taxonomyLeaf;
     TaxonomyTrunk    = taxonomyTrunk;
     TaxonomyBranch   = taxonomyBranch;
     Project          = project;
     IsProject        = Project != null;
     IsTaxonomyLeaf   = TaxonomyLeaf != null && !IsProject;
     IsTaxonomyBranch = TaxonomyBranch != null && !IsTaxonomyLeaf && !IsProject;
     IsTaxonomyTrunk  = TaxonomyTrunk != null && !IsTaxonomyBranch && !IsTaxonomyLeaf && !IsProject;
     TaxonomyLevel    = taxonomyLevel;
 }
Exemple #6
0
 /// <summary>
 /// Constructor for building a new object with MinimalConstructor required fields, using objects whenever possible
 /// </summary>
 public MatchmakerOrganizationTaxonomyLeaf(Organization organization, TaxonomyLeaf taxonomyLeaf, bool isActive) : this()
 {
     // Mark this as a new object by setting primary key with special value
     this.MatchmakerOrganizationTaxonomyLeafID = ModelObjectHelpers.MakeNextUnsavedPrimaryKeyValue();
     this.OrganizationID = organization.OrganizationID;
     this.Organization   = organization;
     organization.MatchmakerOrganizationTaxonomyLeafs.Add(this);
     this.TaxonomyLeafID = taxonomyLeaf.TaxonomyLeafID;
     this.TaxonomyLeaf   = taxonomyLeaf;
     taxonomyLeaf.MatchmakerOrganizationTaxonomyLeafs.Add(this);
     this.IsActive = isActive;
 }
Exemple #7
0
 public void UpdateModel(ProjectFirmaModels.Models.TaxonomyLeaf taxonomyLeaf, FirmaSession currentFirmaSession)
 {
     taxonomyLeaf.TaxonomyLeafName = TaxonomyLeafName;
     taxonomyLeaf.TaxonomyLeafDescriptionHtmlString = TaxonomyLeafDescription;
     taxonomyLeaf.TaxonomyBranchID = !MultiTenantHelpers.IsTaxonomyLevelLeaf()
         ? TaxonomyBranchID
         : HttpRequestStorage.DatabaseEntities.TaxonomyBranches.First().TaxonomyBranchID; // really should only be one
     taxonomyLeaf.ThemeColor = ThemeColor;
     if (!ModelObjectHelpers.IsRealPrimaryKeyValue(taxonomyLeaf.TaxonomyBranchID))
     {
         // for new leaf, set the sort order to greater than the current max for this branch (or null if no leaves have a sort order set)
         var maxSortOrder = HttpRequestStorage.DatabaseEntities.TaxonomyBranches
                            .Where(x => x.TaxonomyTrunkID == taxonomyLeaf.TaxonomyBranchID).Max(x => x.TaxonomyBranchSortOrder);
         taxonomyLeaf.TaxonomyLeafSortOrder = maxSortOrder + 1;
     }
 }
 /// <summary>
 /// Constructor for building a new object with MinimalConstructor required fields, using objects whenever possible
 /// </summary>
 public Project(TaxonomyLeaf taxonomyLeaf, ProjectStage projectStage, string projectName, string projectDescription, bool isFeatured, ProjectLocationSimpleType projectLocationSimpleType, ProjectApprovalStatus projectApprovalStatus, DateTime lastUpdatedDate, ProjectCategory projectCategory, bool locationIsPrivate) : this()
 {
     // Mark this as a new object by setting primary key with special value
     this.ProjectID      = ModelObjectHelpers.MakeNextUnsavedPrimaryKeyValue();
     this.TaxonomyLeafID = taxonomyLeaf.TaxonomyLeafID;
     this.TaxonomyLeaf   = taxonomyLeaf;
     taxonomyLeaf.Projects.Add(this);
     this.ProjectStageID              = projectStage.ProjectStageID;
     this.ProjectName                 = projectName;
     this.ProjectDescription          = projectDescription;
     this.IsFeatured                  = isFeatured;
     this.ProjectLocationSimpleTypeID = projectLocationSimpleType.ProjectLocationSimpleTypeID;
     this.ProjectApprovalStatusID     = projectApprovalStatus.ProjectApprovalStatusID;
     this.LastUpdatedDate             = lastUpdatedDate;
     this.ProjectCategoryID           = projectCategory.ProjectCategoryID;
     this.LocationIsPrivate           = locationIsPrivate;
 }
Exemple #9
0
        public TaxonomyLeaf GetTaxonomyLeaf()
        {
            // There are two ways we can determine TaxonomyLeaf for a give Project:

            // 1) via the Primary Project CAWBS on a CostAuthorityProject record
            var          primaryCostAuthorityProject  = this.CostAuthorityProjects.SingleOrDefault(cap => cap.IsPrimaryProjectCawbs);
            TaxonomyLeaf taxonomyLeafViaCostAuthority = primaryCostAuthorityProject?.CostAuthority?.TaxonomyLeaf;
            // 2) via a deliberate set/override on Project itself, using OverrideTaxonomyLeaf
            TaxonomyLeaf taxonomyLeafViaOverrideOnProject = this.OverrideTaxonomyLeaf;

            // When we were first loading up the database, we only used OverrideTaxonomyLeaf when TaxonomyLeaf wasn't
            // determinable via a CostAuthorityProject record. At the time the code was very
            // rigid about only using one or the other, and the code didn't tolerate both being set.
            //
            // But now that Dorothy is up and using the system, it does seem that we can relax a bit, and
            // start to treat the override like a real override - only used if it is set.
            //
            // Now, we use the override if it is provided, and if not, the PrimaryProjectCAWBs.
            // While we warn internally if they provide the SAME answer (I think we should be able to avoid this being set this way),
            // we no longer care if both the override and the PrimaryProjectCAWBs have different answers.
            //
            // We expect to have AT LEAST one of these work. We don't want TaxonomyLeaf indeterminate.
            //
            // SLG 9/7/2020

            // First, make sure at least one of these gives us an answer. We need to be able to figure out
            // TaxonomyLeaf somehow.
            Check.Ensure(taxonomyLeafViaCostAuthority != null || taxonomyLeafViaOverrideOnProject != null, $"GetTaxonomyLeaf() - both methods return null. Cannot determine TaxonomyLeaf for  Project: {this.ProjectName} ProjectID: {this.ProjectID} ");

            // Next, check to see if they are both set, and to the same thing. Here we can return the
            // right answer, but we will gently warn developers that something may be amiss.(I keep
            // thinking this can be addressed somehow, but I may be wrong.)
            if (taxonomyLeafViaCostAuthority != null && taxonomyLeafViaOverrideOnProject != null)
            {
                if (taxonomyLeafViaCostAuthority.TaxonomyLeafID == taxonomyLeafViaOverrideOnProject.TaxonomyLeafID)
                {
                    string warningMessage = $"GetTaxonomyLeaf() - both methods return a TaxonomyLeaf, but they're the same ({taxonomyLeafViaCostAuthority.TaxonomyLeafID} - {taxonomyLeafViaCostAuthority.TaxonomyLeafName}). You should probably clear the OverrideTaxonomyLeafID on ProjectID {primaryCostAuthorityProject.ProjectID} - {primaryCostAuthorityProject.Project.ProjectName}, since it is redundant. It's also a problem that the data ended up in this state, consider investigating and fixing the bug.";
                    _logger.Warn(warningMessage);
                    return(taxonomyLeafViaCostAuthority);
                }
            }

            // Favor the override if it is given
            return(taxonomyLeafViaOverrideOnProject ?? taxonomyLeafViaCostAuthority);
        }
 public ProjectTaxonomyViewData(ProjectFirmaModels.Models.TaxonomyLeaf taxonomyLeaf, TaxonomyLevel taxonomyLevel) : this(taxonomyLeaf.TaxonomyBranch.TaxonomyTrunk, taxonomyLeaf.TaxonomyBranch, taxonomyLeaf, null, taxonomyLevel)
 {
 }
 /// <summary>
 /// Creates a "blank" object of this type and populates primitives with defaults
 /// </summary>
 public static TaxonomyLeafPerformanceMeasure CreateNewBlank(TaxonomyLeaf taxonomyLeaf, PerformanceMeasure performanceMeasure)
 {
     return(new TaxonomyLeafPerformanceMeasure(taxonomyLeaf, performanceMeasure));
 }
        public ProjectForTaxonomyLeafGridSpec(FirmaSession currentFirmaSession, bool allowTaggingFunctionality, ProjectFirmaModels.Models.TaxonomyLeaf taxonomyLeaf)
        {
            var userHasTagManagePermissions = new FirmaAdminFeature().HasPermissionByFirmaSession(currentFirmaSession);

            if (userHasTagManagePermissions && allowTaggingFunctionality)
            {
                BulkTagModalDialogForm = new BulkTagModalDialogForm(SitkaRoute <TagController> .BuildUrlFromExpression(x => x.BulkTagProjects(null)), $"Tag Checked {FieldDefinitionEnum.Project.ToType().GetFieldDefinitionLabelPluralized()}", $"Tag {FieldDefinitionEnum.Project.ToType().GetFieldDefinitionLabelPluralized()}");
                AddCheckBoxColumn();
                Add("ProjectID", x => x.ProjectID, 0);
            }

            Add(string.Empty, x => UrlTemplate.MakeHrefString(x.GetFactSheetUrl(), FirmaDhtmlxGridHtmlHelpers.FactSheetIcon.ToString()), 30, DhtmlxGridColumnFilterType.None);
            Add(FieldDefinitionEnum.ProjectName.ToType().ToGridHeaderString(), x => UrlTemplate.MakeHrefString(x.GetDetailUrl(), x.ProjectName), 300, DhtmlxGridColumnFilterType.Html);
            if (MultiTenantHelpers.GetTenantAttributeFromCache().EnableSecondaryProjectTaxonomyLeaf)
            {
                Add($"Relationship to {FieldDefinitionEnum.TaxonomyLeaf.ToType().GetFieldDefinitionLabel()}",
                    x => x.GetTaxonomyLeaf().TaxonomyLeafID == taxonomyLeaf.TaxonomyLeafID ? "Primary" : "Secondary",
                    100, DhtmlxGridColumnFilterType.SelectFilterStrict);
            }
            if (MultiTenantHelpers.HasCanStewardProjectsOrganizationRelationship())
            {
                Add(FieldDefinitionEnum.ProjectsStewardOrganizationRelationshipToProject.ToType().ToGridHeaderString(), x => x.GetCanStewardProjectsOrganization().GetShortNameAsUrl(), 150,
                    DhtmlxGridColumnFilterType.Html);
            }
            Add(FieldDefinitionEnum.IsPrimaryContactOrganization.ToType().ToGridHeaderString(), x => x.GetPrimaryContactOrganization().GetShortNameAsUrl(), 150, DhtmlxGridColumnFilterType.Html);
            Add(FieldDefinitionEnum.ProjectStage.ToType().ToGridHeaderString(), x => x.ProjectStage.ProjectStageDisplayName, 90, DhtmlxGridColumnFilterType.SelectFilterStrict);
            Add(FieldDefinitionEnum.PlanningDesignStartYear.ToType().ToGridHeaderString(), x => x.GetPlanningDesignStartYear(), 90, DhtmlxGridColumnFilterType.SelectFilterStrict);
            Add(FieldDefinitionEnum.ImplementationStartYear.ToType().ToGridHeaderString(), x => x.GetImplementationStartYear(), 115, DhtmlxGridColumnFilterType.SelectFilterStrict);
            Add(FieldDefinitionEnum.CompletionYear.ToType().ToGridHeaderString(), x => x.GetCompletionYear(), 90, DhtmlxGridColumnFilterType.SelectFilterStrict);
            Add(FieldDefinitionEnum.FundingType.ToType().ToGridHeaderString(), x => x.FundingType?.FundingTypeDisplayName, 300, DhtmlxGridColumnFilterType.SelectFilterStrict);
            Add(FieldDefinitionEnum.EstimatedTotalCost.ToType().ToGridHeaderString(), x => x.GetEstimatedTotalRegardlessOfFundingType(), 110, DhtmlxGridColumnFormatType.Currency, DhtmlxGridColumnAggregationType.Total);

            Add(FieldDefinitionEnum.ProjectedFunding.ToType().ToGridHeaderString(), x => x.GetProjectedFunding(), 100, DhtmlxGridColumnFormatType.Currency, DhtmlxGridColumnAggregationType.Total);
            Add(FieldDefinitionEnum.NoFundingSourceIdentified.ToType().ToGridHeaderString(), x => x.GetNoFundingSourceIdentifiedAmount(), 110, DhtmlxGridColumnFormatType.Currency, DhtmlxGridColumnAggregationType.Total);
            foreach (var geospatialAreaType in new List <GeospatialAreaType>())
            {
                Add($"{geospatialAreaType.GeospatialAreaTypeNamePluralized}", a => a.GetProjectGeospatialAreaNamesAsHyperlinks(geospatialAreaType), 350, DhtmlxGridColumnFilterType.Html);
            }
            Add(FieldDefinitionEnum.ProjectDescription.ToType().ToGridHeaderString(), x => x.ProjectDescription, 300);
            if (userHasTagManagePermissions)
            {
                Add("Tags", x => new HtmlString(!x.ProjectTags.Any() ? string.Empty : string.Join(", ", x.ProjectTags.Select(pt => pt.Tag.GetDisplayNameAsUrl()))), 100, DhtmlxGridColumnFilterType.Html);
            }
        }
 /// <summary>
 /// Creates a "blank" object of this type and populates primitives with defaults
 /// </summary>
 public static CostAuthority CreateNewBlank(TaxonomyLeaf taxonomyLeaf)
 {
     return(new CostAuthority(taxonomyLeaf));
 }
Exemple #14
0
 /// <summary>
 /// Creates a "blank" object of this type and populates primitives with defaults
 /// </summary>
 public static MatchmakerOrganizationTaxonomyLeaf CreateNewBlank(Organization organization, TaxonomyLeaf taxonomyLeaf)
 {
     return(new MatchmakerOrganizationTaxonomyLeaf(organization, taxonomyLeaf, default(bool)));
 }
Exemple #15
0
 /// <summary>
 /// Creates a "blank" object of this type and populates primitives with defaults
 /// </summary>
 public static SecondaryProjectTaxonomyLeaf CreateNewBlank(Project project, TaxonomyLeaf taxonomyLeaf)
 {
     return(new SecondaryProjectTaxonomyLeaf(project, taxonomyLeaf));
 }
 /// <summary>
 /// Creates a "blank" object of this type and populates primitives with defaults
 /// </summary>
 public static Project CreateNewBlank(TaxonomyLeaf taxonomyLeaf, ProjectStage projectStage, ProjectLocationSimpleType projectLocationSimpleType, ProjectApprovalStatus projectApprovalStatus, ProjectCategory projectCategory)
 {
     return(new Project(taxonomyLeaf, projectStage, default(string), default(string), default(bool), projectLocationSimpleType, projectApprovalStatus, default(DateTime), projectCategory, default(bool)));
 }
Exemple #17
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;
        }