Пример #1
0
        private PartialViewResult ViewDeleteOrganization(Organization organization, ConfirmDialogFormViewModel viewModel)
        {
            var projectGrantAllocationExpenditureTotal = organization.GrantAllocations.Sum(x => x.ProjectGrantAllocationExpenditures.Sum(y => y.ExpenditureAmount)).ToStringCurrency();
            var confirmMessage = $"{FieldDefinition.Organization.GetFieldDefinitionLabel()} \"{organization.OrganizationName}\" is related to {organization.ProjectOrganizations.Count} projects and has {organization.GrantAllocations.Count} Grant Allocations that fund a total of {projectGrantAllocationExpenditureTotal} across various projects.<br /><br />Are you sure you want to delete this Organization?";
            var viewData       = new ConfirmDialogFormViewData(confirmMessage, true);

            return(RazorPartialView <ConfirmDialogForm, ConfirmDialogFormViewData, ConfirmDialogFormViewModel>(viewData, viewModel));
        }
Пример #2
0
        private PartialViewResult ViewDeleteOrganizationBoundary(Organization organization,
                                                                 ConfirmDialogFormViewModel viewModel)
        {
            var viewData = new ConfirmDialogFormViewData(
                $"Are you sure you want to delete the boundary for this {FieldDefinition.Organization.GetFieldDefinitionLabel()} '{organization.OrganizationName}'?");

            return(RazorPartialView <ConfirmDialogForm, ConfirmDialogFormViewData, ConfirmDialogFormViewModel>(viewData,
                                                                                                               viewModel));
        }
Пример #3
0
        private static List <Agreement> GetAgreementsByOrgPeople(Organization organization)
        {
            var orgContacts          = organization.People;
            var orgContactAgreements =
                orgContacts.SelectMany(x => x.AgreementPeople).Select(x => x.AgreementID).Distinct();
            var agreements = HttpRequestStorage.DatabaseEntities.Agreements
                             .Where(a => orgContactAgreements.Contains(a.AgreementID)).OrderBy(a => a.AgreementNumber).ToList();

            return(agreements);
        }
Пример #4
0
        private static MapInitJson GetMapInitJson(Organization organization, out bool hasSpatialData, Person person)
        {
            hasSpatialData = false;

            var layers = new List <LayerGeoJson>();

            if (organization.OrganizationBoundary != null)
            {
                hasSpatialData = true;
                layers.Add(new LayerGeoJson("Organization Boundary",
                                            organization.OrganizationBoundaryToFeatureCollection(), organization.OrganizationType?.LegendColor ?? FirmaHelpers.DefaultColorRange.First(), 1,
                                            LayerInitialVisibility.Show));
            }

            var allActiveProjectsAndProposals = organization.GetAllActiveProjectsAndProposals(person).Where(x => x.ProjectStage.ShouldShowOnMap()).ToList();

            var projectsAsSimpleLocations = allActiveProjectsAndProposals.Where(x => x.ProjectLocationSimpleType != ProjectLocationSimpleType.None).ToList();
            var projectSimpleLocationsFeatureCollection = new FeatureCollection();
            var allProjectGrantAllocationExpenditures   =
                HttpRequestStorage.DatabaseEntities.ProjectGrantAllocationExpenditures.ToList();
            var projectGrantAllocationExpenditureDict = allProjectGrantAllocationExpenditures.GroupBy(x => x.ProjectID).ToDictionary(x => x.Key, y => y.ToList());

            projectSimpleLocationsFeatureCollection.Features.AddRange(projectsAsSimpleLocations.Select(x =>
            {
                var feature = x.MakePointFeatureWithRelevantProperties(x.ProjectLocationPoint, true, true, FieldDefinition.Organization.GetFieldDefinitionLabel(), FieldDefinition.Organization.GetFieldDefinitionLabelPluralized(), projectGrantAllocationExpenditureDict);
                feature.Properties["FeatureColor"] = "#99b3ff";
                return(feature);
            }).ToList());

            if (projectSimpleLocationsFeatureCollection.Features.Any())
            {
                hasSpatialData = true;
                layers.Add(new LayerGeoJson("Projects", projectSimpleLocationsFeatureCollection, "blue", 1, LayerInitialVisibility.Show));
            }

            var projectDetailLocationsFeatureCollection = allActiveProjectsAndProposals.SelectMany(x => x.GetProjectLocationDetails()).ToGeoJsonFeatureCollection();

            if (projectDetailLocationsFeatureCollection.Features.Any())
            {
                hasSpatialData = true;
                layers.Add(new LayerGeoJson($"{FieldDefinition.Project.GetFieldDefinitionLabel()} Detailed Mapping", projectDetailLocationsFeatureCollection, "blue", 1, LayerInitialVisibility.Hide));
            }

            var boundingBox = BoundingBox.MakeBoundingBoxFromLayerGeoJsonList(layers);

            layers.AddRange(MapInitJson.GetAllGeospatialAreaMapLayers(LayerInitialVisibility.Show));

            return(new MapInitJson($"organization_{organization.OrganizationID}_Map", 10, layers, boundingBox));
        }
Пример #5
0
        public ActionResult New(EditViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                return(ViewEdit(viewModel, true, null));
            }
            var organization = new Organization(String.Empty, String.Empty, true, ModelObjectHelpers.NotYetAssignedID, true);

            viewModel.UpdateModel(organization, CurrentPerson);
            HttpRequestStorage.DatabaseEntities.Organizations.Add(organization);
            HttpRequestStorage.DatabaseEntities.SaveChanges();
            SetMessageForDisplay($"{FieldDefinition.Organization.GetFieldDefinitionLabel()} {organization.DisplayName} successfully created.");

            return(new ModalDialogFormJsonResult());
        }
Пример #6
0
 public static string GetDetailUrl(this Organization organization)
 {
     return(organization == null ? "" : SummaryUrlTemplate.ParameterReplace(organization.OrganizationID));
 }
Пример #7
0
 public static string GetDetailProfileTabUrl(this Organization organization)
 {
     return(organization == null ? "" : DetailProfileTabUrlTemplate.ParameterReplace(organization.OrganizationID));
 }
Пример #8
0
 public static HtmlString GetDisplayNameAsUrl(this Organization organization)
 {
     return(organization != null?UrlTemplate.MakeHrefString(organization.GetDetailUrl(), organization.GetDisplayName()) : new HtmlString(null));
 }
Пример #9
0
 public static HtmlString GetShortNameAsUrl(this Organization organization)
 {
     return(organization != null?UrlTemplate.MakeHrefString(organization.GetDetailUrl(), organization.OrganizationShortName ?? organization.OrganizationName) : new HtmlString(null));
 }
Пример #10
0
        private static ViewGoogleChartViewData GetCalendarYearExpendituresFromProjectGrantAllocationsLineChartViewData(Organization organization, Person currentPerson)
        {
            var yearRange = FirmaDateUtilities.GetRangeOfYearsForReporting();

            var projects = organization.GetAllActiveProjectsAndProposalsWhereOrganizationIsStewardOrPrimaryContact(currentPerson).ToList();
            var projectGrantAllocationExpenditures = projects.SelectMany(x => x.ProjectGrantAllocationExpenditures).Where(x => x.GrantAllocation.BottommostOrganization != organization);

            var chartTitle       = $"{FieldDefinition.ReportedExpenditure.GetFieldDefinitionLabelPluralized()} By {FieldDefinition.OrganizationType.GetFieldDefinitionLabel()}";
            var chartContainerID = chartTitle.Replace(" ", "");
            var filterValues     = projects.SelectMany(x => x.ProjectGrantAllocationExpenditures).Where(x => x.GrantAllocation.BottommostOrganization != organization).Select(x => x.GrantAllocation.BottommostOrganization.OrganizationType.OrganizationTypeName).Distinct().ToList();

            var googleChart = projectGrantAllocationExpenditures.ToGoogleChart(x => x.GrantAllocation.BottommostOrganization.OrganizationType.OrganizationTypeName,
                                                                               filterValues,
                                                                               x => x.GrantAllocation.BottommostOrganization.OrganizationType.OrganizationTypeName,
                                                                               yearRange,
                                                                               chartContainerID,
                                                                               chartTitle,
                                                                               GoogleChartType.AreaChart,
                                                                               true);

            return(new ViewGoogleChartViewData(googleChart, chartTitle, 400, true));
        }
Пример #11
0
 public static bool CanStewardProjects(this Organization organization)
 {
     return(organization.OrganizationType.OrganizationTypeOrganizationRelationshipTypes.Any(x => x.OrganizationRelationshipTypeID == MultiTenantHelpers.GetCanStewardProjectsOrganizationRelationship()?.OrganizationRelationshipTypeID));
 }
Пример #12
0
 private static bool HasMatchmakerKeywordContent(this Organization organization)
 {
     // Are any Matchmaker Keywords defined for this Organization?
     return(organization.OrganizationMatchmakerKeywords.Any());
 }
Пример #13
0
        public static List <Project> GetAllActiveProjectsAndProposalsWhereOrganizationIsStewardOrPrimaryContact(this Organization organization, FirmaSession firmaSession)
        {
            var allActiveProjectsAndProposals = organization.GetAllAssociatedProjects().GetActiveProjectsAndProposals(firmaSession.CanViewProposals());

            if (MultiTenantHelpers.HasCanStewardProjectsOrganizationRelationship())
            {
                return(allActiveProjectsAndProposals.Where(x => x.GetCanStewardProjectsOrganization() == organization).ToList());
            }

            return(allActiveProjectsAndProposals.Where(x => x.GetPrimaryContactOrganization() == organization).ToList());
        }
Пример #14
0
 public static string GetPrimaryContactPersonAsString(this Organization organization) => organization.PrimaryContactPerson != null
     ? organization.PrimaryContactPerson.GetFullNameFirstLast()
     : ViewUtilities.NoneString;
Пример #15
0
 private static bool HasMatchmakerTaxonomyContent(this Organization organization)
 {
     return(organization.MatchmakerOrganizationTaxonomyLeafs.Any() || organization.MatchmakerOrganizationTaxonomyBranches.Any() || organization.MatchmakerOrganizationTaxonomyTrunks.Any());
 }
Пример #16
0
 public static HtmlString GetPrimaryContactPersonWithOrgAsUrl(this Organization organization, FirmaSession currentFirmaSession) => organization.PrimaryContactPerson != null
     ? organization.PrimaryContactPerson.GetFullNameFirstLastAndOrgAsUrl(currentFirmaSession)
     : new HtmlString(ViewUtilities.NoneString);
Пример #17
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="gisFile"></param>
        /// <param name="originalFilename">This is the original name of the file as it appeared on the users file system. It is provided just for error messaging purposes.</param>
        /// <param name="organization"></param>
        /// <returns></returns>
        public static List <OrganizationBoundaryStaging> CreateOrganizationBoundaryStagingStagingListFromGdb(FileInfo gisFile, string originalFilename, Organization organization)
        {
            var ogr2OgrCommandLineRunner = new Ogr2OgrCommandLineRunner(FirmaWebConfiguration.Ogr2OgrExecutable,
                                                                        LtInfoGeometryConfiguration.DefaultCoordinateSystemId,
                                                                        FirmaWebConfiguration.HttpRuntimeExecutionTimeout.TotalMilliseconds);

            var geoJsons =
                OgrInfoCommandLineRunner.GetFeatureClassNamesFromFileGdb(new FileInfo(FirmaWebConfiguration.OgrInfoExecutable), gisFile, originalFilename, Ogr2OgrCommandLineRunner.DefaultTimeOut)
                .ToDictionary(x => x, x => ogr2OgrCommandLineRunner.ImportFileGdbToGeoJson(gisFile, x, false))
                .Where(x => OrganizationBoundaryStaging.IsUsableFeatureCollectionGeoJson(JsonTools.DeserializeObject <FeatureCollection>(x.Value)))
                .ToDictionary(x => x.Key, x => new FeatureCollection(JsonTools.DeserializeObject <FeatureCollection>(x.Value).Features.Where(OrganizationBoundaryStaging.IsUsableFeatureGeoJson).ToList()).ToGeoJsonString());

            Check.Assert(geoJsons.Count != 0, "Number of usable Feature Classes in uploaded file must be greater than 0.");

            return(geoJsons.Select(x => new OrganizationBoundaryStaging(organization, x.Key, x.Value)).ToList());
        }
Пример #18
0
        public static PerformanceMeasureChartViewData GetPerformanceMeasureChartViewData(this Organization organization,
                                                                                         PerformanceMeasure performanceMeasure,
                                                                                         FirmaSession firmaSession)
        {
            var projects = organization.GetAllActiveProjectsAndProposals(firmaSession).ToList();

            return(new PerformanceMeasureChartViewData(performanceMeasure, firmaSession, false, projects));
        }
Пример #19
0
 public static HtmlString GetDisplayNameWithoutAbbreviationAsProfileTabUrl(this Organization organization)
 {
     return(organization != null
         ? UrlTemplate.MakeHrefString(organization.GetDetailProfileTabUrl(), organization.GetDisplayNameWithoutAbbreviation())
         : new HtmlString(null));
 }
Пример #20
0
 public static bool CanBeReportedInAccomplishmentsDashboard(this Organization organization)
 {
     return(organization.OrganizationType.OrganizationTypeOrganizationRelationshipTypes.Any(x =>
                                                                                            x.OrganizationRelationshipTypeID == MultiTenantHelpers
                                                                                            .GetOrganizationRelationshipTypeToReportInAccomplishmentsDashboard()?.OrganizationRelationshipTypeID));
 }
Пример #21
0
 public static string GetDisplayNameWithoutAbbreviation(this Organization organization) => organization.IsUnknown()
     ? "Unknown or unspecified"
     : $"{organization.OrganizationName}{(!organization.IsActive ? " (Inactive)" : String.Empty)}";
Пример #22
0
 public static List <Project> GetAllActiveProjectsWhereOrganizationReportsInAccomplishmentsDashboard(this Organization organization)
 {
     Check.Assert(MultiTenantHelpers.DisplayAccomplishmentDashboard());
     return(organization.GetAllAssociatedProjects()
            .GetActiveProjectsAndProposals(MultiTenantHelpers.ShowProposalsToThePublic())
            .Where(x => x.GetOrganizationsToReportInAccomplishments().Any(y => y == organization))
            .ToList());
 }
Пример #23
0
        private static ViewGoogleChartViewData GetCalendarYearExpendituresFromOrganizationGrantAllocationsLineChartViewData(Organization organization)
        {
            var yearRange = FirmaDateUtilities.GetRangeOfYearsForReporting();
            var projectGrantAllocationExpenditures = organization.GrantAllocations.SelectMany(x => x.ProjectGrantAllocationExpenditures);

            var chartTitle       = $"{FieldDefinition.ReportedExpenditure.GetFieldDefinitionLabelPluralized()} By {FieldDefinition.GrantAllocation.GetFieldDefinitionLabel()}";
            var chartContainerID = chartTitle.Replace(" ", "");
            var filterValues     = organization.GrantAllocations.Select(x => x.GrantAllocationName).Distinct().ToList();
            var googleChart      = projectGrantAllocationExpenditures.ToGoogleChart(x => x.GrantAllocation.GrantAllocationName,
                                                                                    filterValues,
                                                                                    x => x.GrantAllocation.GrantAllocationName,
                                                                                    yearRange,
                                                                                    chartContainerID,
                                                                                    chartTitle,
                                                                                    GoogleChartType.AreaChart,
                                                                                    true);

            return(new ViewGoogleChartViewData(googleChart, chartTitle, 400, true));
        }
Пример #24
0
 public static List <Project> GetAllPendingProjects(this Organization organization, Person person)
 {
     return(organization.GetAllAssociatedProjects().GetPendingProjects(person.CanViewPendingProjects()));
 }
Пример #25
0
 private static bool HasMatchmakerClassificationsContent(this Organization organization)
 {
     return(organization.MatchmakerOrganizationClassifications.Any());
 }
Пример #26
0
 public static bool CanBeAPrimaryContactOrganization(this Organization organization)
 {
     return(organization.OrganizationType.OrganizationTypeOrganizationRelationshipTypes.Any(x => x.OrganizationRelationshipTypeID == MultiTenantHelpers.GetIsPrimaryContactOrganizationRelationship()?.OrganizationRelationshipTypeID));
 }
Пример #27
0
        private PartialViewResult ViewApproveUploadGis(ApproveUploadGisViewModel viewModel, Organization organization)
        {
            var layers = organization.OrganizationBoundaryStagings.Select((x, index) => new LayerGeoJson(
                                                                              x.FeatureClassName, x.ToGeoJsonFeatureCollection(),
                                                                              FirmaHelpers.DefaultColorRange[index], 0.8m,
                                                                              index == 0 ? LayerInitialVisibility.Show : LayerInitialVisibility.Hide)).ToList();
            var mapInitJson = new MapInitJson("organizationBoundaryApproveUploadGisMap", 10, layers, BoundingBox.MakeBoundingBoxFromLayerGeoJsonList(layers));

            var viewData = new ApproveUploadGisViewData(CurrentPerson, organization, mapInitJson);

            return(RazorPartialView <ApproveUploadGis, ApproveUploadGisViewData, ApproveUploadGisViewModel>(viewData, viewModel));
        }
Пример #28
0
 private static bool HasMatchmakerPerformanceMeasureContent(this Organization organization)
 {
     return(organization.MatchmakerOrganizationPerformanceMeasures.Any());
 }
Пример #29
0
 public static string GetDeleteUrl(this Organization organization)
 {
     return(DeleteUrlTemplate.ParameterReplace(organization.OrganizationID));
 }
Пример #30
0
 public static List <Project> GetProposalsVisibleToUser(this Organization organization, FirmaSession firmaSession)
 {
     return(organization.GetAllAssociatedProjects().GetProposalsVisibleToUser(firmaSession));
 }