Esempio n. 1
0
 public void UpdateModel(ProjectFirmaModels.Models.Organization organization)
 {
     using (var disposableTempFile = DisposableTempFile.MakeDisposableTempFileEndingIn(".gdb.zip"))
     {
         var gdbFile = disposableTempFile.FileInfo;
         FileResourceData.SaveAs(gdbFile.FullName);
         HttpRequestStorage.DatabaseEntities.AllOrganizationBoundaryStagings.RemoveRange(organization.OrganizationBoundaryStagings.ToList());
         organization.OrganizationBoundaryStagings.Clear();
         OrganizationModelExtensions.CreateOrganizationBoundaryStagingStagingListFromGdb(gdbFile, FileResourceData.FileName, organization);
     }
 }
Esempio n. 2
0
 public EditViewModelValidator()
 {
     RuleFor(x => x.OrganizationName)
     .NotEmpty()
     .WithMessage("Organization name is required")
     .Length(1, ProjectFirmaModels.Models.Organization.FieldLengths.OrganizationName)
     .Must((viewModel, organizationName) => OrganizationModelExtensions.IsOrganizationNameUnique(Organizations(), organizationName, viewModel.OrganizationID))
     .WithMessage(FirmaValidationMessages.OrganizationNameUnique);
     RuleFor(x => x.OrganizationShortName)
     .Must((viewModel, organizationShortName) => OrganizationModelExtensions.IsOrganizationShortNameUniqueIfProvided(Organizations(), organizationShortName, viewModel.OrganizationID))
     .WithMessage(FirmaValidationMessages.OrganizationShortNameUnique);
     RuleFor(x => x.IsActive).NotEmpty().WithMessage("Is Active is required");
 }
Esempio n. 3
0
        private void AddProjectCustomGridField(FirmaSession currentFirmaSession
                                               , ProjectCustomGridConfiguration projectCustomGridConfiguration
                                               , bool userHasEditProjectAsAdminPermissions
                                               , Dictionary <int, vProjectDetail> projectDetailsDictionary
                                               , Dictionary <int, ProjectFirmaModels.Models.TaxonomyLeaf> taxonomyLeafDictionary
                                               , string projectLabel
                                               , bool hasProjectApprovalPermissionBySession
                                               , string statusUpdateLabel
                                               , List <int> sitkaAdminPersonIDs)
        {
            switch (projectCustomGridConfiguration.ProjectCustomGridColumn.ToEnum)
            {
            // Non-optional fields
            // Project Name
            case ProjectCustomGridColumnEnum.ProjectName:
                Add(FieldDefinitionEnum.ProjectName.ToType().ToGridHeaderString(), x => UrlTemplate.MakeHrefString(x.GetDetailUrl(), x.ProjectName), 300, DhtmlxGridColumnFilterType.Html);
                break;

            case ProjectCustomGridColumnEnum.PrimaryContactOrganization:
                Add(FieldDefinitionEnum.IsPrimaryContactOrganization.ToType().ToGridHeaderString(),
                    x => OrganizationModelExtensions.GetShortNameAsUrl(projectDetailsDictionary[x.ProjectID].PrimaryContactOrganizationID, projectDetailsDictionary[x.ProjectID].PrimaryContactOrganizationDisplayName), 150, DhtmlxGridColumnFilterType.Html);
                break;

            case ProjectCustomGridColumnEnum.ProjectStage:
                Add(FieldDefinitionEnum.ProjectStage.ToType().ToGridHeaderString(), x => x.ProjectStage.ProjectStageDisplayName, 90, DhtmlxGridColumnFilterType.SelectFilterStrict);
                break;

            case ProjectCustomGridColumnEnum.NumberOfExpectedPerformanceMeasureRecords:
                Add($"# Of Expected {MultiTenantHelpers.GetPerformanceMeasureName()} Records", x => projectDetailsDictionary[x.ProjectID].PerformanceMeasureExpectedCount, 100);
                break;

            case ProjectCustomGridColumnEnum.NumberOfReportedPerformanceMeasures:
                Add($"# Of Reported {MultiTenantHelpers.GetPerformanceMeasureName()} Records", x => projectDetailsDictionary[x.ProjectID].PerformanceMeasureActualCount, 100);
                break;

            case ProjectCustomGridColumnEnum.ProjectsStewardOrganizationRelationshipToProject:
                if (MultiTenantHelpers.HasCanStewardProjectsOrganizationRelationship())
                {
                    Add(FieldDefinitionEnum.ProjectsStewardOrganizationRelationshipToProject.ToType().ToGridHeaderString(), x => OrganizationModelExtensions.GetShortNameAsUrl(projectDetailsDictionary[x.ProjectID].CanStewardProjectsOrganizationID, projectDetailsDictionary[x.ProjectID].CanStewardProjectsOrganizationDisplayName), 150, DhtmlxGridColumnFilterType.Html);
                }
                break;

            case ProjectCustomGridColumnEnum.ProjectPrimaryContact:
                Add(FieldDefinitionEnum.ProjectPrimaryContact.ToType().ToGridHeaderString(),
                    x => projectDetailsDictionary[x.ProjectID].PrimaryContactPersonID.HasValue ?
                    new UserViewFeature().HasPermissionForPersonID(currentFirmaSession, projectDetailsDictionary[x.ProjectID].PrimaryContactPersonID.Value, sitkaAdminPersonIDs).HasPermission ? UrlTemplate.MakeHrefString(PersonModelExtensions.DetailUrlTemplate.ParameterReplace(projectDetailsDictionary[x.ProjectID].PrimaryContactPersonID.Value), projectDetailsDictionary[x.ProjectID].PrimaryContactPersonFullNameFirstLast) : new HtmlString(projectDetailsDictionary[x.ProjectID].PrimaryContactPersonFullNameFirstLast) : new HtmlString(""),
                    150, DhtmlxGridColumnFilterType.Html);
                break;

            case ProjectCustomGridColumnEnum.ProjectPrimaryContactEmail:
                var userHasEmailViewingPermissions = new LoggedInAndNotUnassignedRoleUnclassifiedFeature().HasPermissionByFirmaSession(currentFirmaSession);
                if (userHasEmailViewingPermissions)
                {
                    Add(FieldDefinitionEnum.ProjectPrimaryContactEmail.ToType().ToGridHeaderString(),
                        x => projectDetailsDictionary[x.ProjectID].PrimaryContactPersonID.HasValue ? new HtmlString($"<a href='mailto:{projectDetailsDictionary[x.ProjectID].PrimaryContactPersonEmail}'> {projectDetailsDictionary[x.ProjectID].PrimaryContactPersonEmail}</a>") : new HtmlString(""),
                        200, DhtmlxGridColumnFilterType.SelectFilterHtmlStrict);
                }
                break;

            case ProjectCustomGridColumnEnum.PlanningDesignStartYear:
                Add(FieldDefinitionEnum.PlanningDesignStartYear.ToType().ToGridHeaderString(), x => ProjectModelExtensions.GetPlanningDesignStartYear(x), 90, DhtmlxGridColumnFilterType.SelectFilterStrict);
                break;

            case ProjectCustomGridColumnEnum.ImplementationStartYear:
                Add(FieldDefinitionEnum.ImplementationStartYear.ToType().ToGridHeaderString(), x => ProjectModelExtensions.GetImplementationStartYear(x), 115, DhtmlxGridColumnFilterType.SelectFilterStrict);
                break;

            case ProjectCustomGridColumnEnum.CompletionYear:
                Add(FieldDefinitionEnum.CompletionYear.ToType().ToGridHeaderString(), x => ProjectModelExtensions.GetCompletionYear(x), 90, DhtmlxGridColumnFilterType.SelectFilterStrict);
                break;

            case ProjectCustomGridColumnEnum.PrimaryTaxonomyLeaf:
                var gridHeaderString = MultiTenantHelpers.GetTenantAttributeFromCache().EnableSecondaryProjectTaxonomyLeaf
                        ? FieldDefinitionEnum.TaxonomyLeafDisplayNameForProject.ToType().ToGridHeaderString()
                        : FieldDefinitionEnum.TaxonomyLeaf.ToType().ToGridHeaderString();
                Add(gridHeaderString, x => UrlTemplate.MakeHrefString(TaxonomyLeafModelExtensions.DetailUrlTemplate.ParameterReplace(projectDetailsDictionary[x.ProjectID].TaxonomyLeafID), projectDetailsDictionary[x.ProjectID].TaxonomyLeafDisplayName), 240, DhtmlxGridColumnFilterType.Html);
                break;

            case ProjectCustomGridColumnEnum.SecondaryTaxonomyLeaf:
                if (MultiTenantHelpers.GetTenantAttributeFromCache().EnableSecondaryProjectTaxonomyLeaf)
                {
                    Add(FieldDefinitionEnum.SecondaryProjectTaxonomyLeaf.ToType().ToGridHeaderStringPlural()
                        , x => new HtmlString(string.Join(", ", x.SecondaryProjectTaxonomyLeafs.Select(y => taxonomyLeafDictionary[y.TaxonomyLeafID].GetDisplayNameAsUrl().ToString()))), 300, DhtmlxGridColumnFilterType.Html);
                }
                break;

            case ProjectCustomGridColumnEnum.NumberOfReportedExpenditures:
                Add($"# Of {FieldDefinitionEnum.ReportedExpenditure.ToType().GetFieldDefinitionLabel()} Records", x => projectDetailsDictionary[x.ProjectID].ProjectFundingSourceExpenditureCount, 100);
                break;

            case ProjectCustomGridColumnEnum.FundingType:
                Add(FieldDefinitionEnum.FundingType.ToType().ToGridHeaderString(), x => x.FundingType != null ? x.FundingType.FundingTypeDisplayName : "", 300, DhtmlxGridColumnFilterType.SelectFilterStrict);
                break;

            case ProjectCustomGridColumnEnum.EstimatedTotalCost:
                Add(FieldDefinitionEnum.EstimatedTotalCost.ToType().ToGridHeaderString(), x => x.GetEstimatedTotalRegardlessOfFundingType(), 110, DhtmlxGridColumnFormatType.Currency, DhtmlxGridColumnAggregationType.Total);
                break;

            case ProjectCustomGridColumnEnum.SecuredFunding:
                Add(FieldDefinitionEnum.SecuredFunding.ToType().ToGridHeaderString(), x => x.GetSecuredFunding(), 110, DhtmlxGridColumnFormatType.Currency, DhtmlxGridColumnAggregationType.Total);
                break;

            case ProjectCustomGridColumnEnum.TargetedFunding:
                Add(FieldDefinitionEnum.TargetedFunding.ToType().ToGridHeaderString(), x => x.GetTargetedFunding(), 100, DhtmlxGridColumnFormatType.Currency, DhtmlxGridColumnAggregationType.Total);
                break;

            case ProjectCustomGridColumnEnum.NoFundingSourceIdentified:
                Add(FieldDefinitionEnum.NoFundingSourceIdentified.ToType().ToGridHeaderString(), x => x.GetNoFundingSourceIdentifiedAmount(), 110, DhtmlxGridColumnFormatType.Currency, DhtmlxGridColumnAggregationType.Total);
                break;

            case ProjectCustomGridColumnEnum.ProjectDescription:
                Add(FieldDefinitionEnum.ProjectDescription.ToType().ToGridHeaderString(), x => x.ProjectDescription, 200);
                break;

            case ProjectCustomGridColumnEnum.NumberOfPhotos:
                Add("# of Photos", x => projectDetailsDictionary[x.ProjectID].ProjectImageCount, 60);
                break;

            case ProjectCustomGridColumnEnum.ProjectID:
                Add(FieldDefinitionEnum.ProjectID.ToType().ToGridHeaderString(), x => x.ProjectID.ToString(), 140);
                break;

            case ProjectCustomGridColumnEnum.ProjectLastUpdated:
                Add(FieldDefinitionEnum.ProjectLastUpdated.ToType().ToGridHeaderString(), x => x.LastUpdatedDate, 140);
                break;

            case ProjectCustomGridColumnEnum.ProjectStatus:
                if (MultiTenantHelpers.GetTenantAttributeFromCache().UseProjectTimeline&& userHasEditProjectAsAdminPermissions)
                {
                    Add(FieldDefinitionEnum.Status.ToType().ToGridHeaderString()
                        , x => MakeProjectStatusAddLinkAndText(x, currentFirmaSession, projectDetailsDictionary[x.ProjectID], projectLabel, hasProjectApprovalPermissionBySession, statusUpdateLabel)
                        , 100
                        , DhtmlxGridColumnFilterType.SelectFilterHtmlStrict
                        );
                }
                break;

            case ProjectCustomGridColumnEnum.FinalStatusUpdateStatus:
                if (MultiTenantHelpers.GetTenantAttributeFromCache().UseProjectTimeline&& userHasEditProjectAsAdminPermissions)
                {
                    Add(FieldDefinitionEnum.FinalStatusUpdateStatus.ToType().ToGridHeaderString()
                        , x => projectDetailsDictionary[x.ProjectID].FinalStatusReportStatusDescription
                        , 100
                        , DhtmlxGridColumnFilterType.SelectFilterStrict
                        );
                }
                break;

            case ProjectCustomGridColumnEnum.GeospatialAreaName:
                break;

            case ProjectCustomGridColumnEnum.CustomAttribute:
                break;

            case ProjectCustomGridColumnEnum.ProjectCategory:
                if (MultiTenantHelpers.GetTenantAttributeFromCache().EnableProjectCategories)
                {
                    Add(FieldDefinitionEnum.ProjectCategory.ToType().ToGridHeaderString(), x => x.ProjectCategory.ProjectCategoryDisplayName, 140, DhtmlxGridColumnFilterType.SelectFilterStrict);
                }
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }