public static TreatmentBMPBenchmarkAndThreshold Create(Models.TreatmentBMP treatmentBMP, TreatmentBMPAssessmentObservationType TreatmentBMPAssessmentObservationType) { var treatmentBMPType = treatmentBMP.TreatmentBMPType; var TreatmentBMPTypeAssessmentObservationType = TestTreatmentBMPTypeObservationType.Create(treatmentBMPType, TreatmentBMPAssessmentObservationType); return(TreatmentBMPBenchmarkAndThreshold.CreateNewBlank(treatmentBMP, TreatmentBMPTypeAssessmentObservationType, treatmentBMPType, TreatmentBMPAssessmentObservationType)); }
public InstructionsViewData(Person currentPerson, Models.TreatmentBMP treatmentBMP) : base(currentPerson, treatmentBMP) { NextSectionUrl = treatmentBMP.HasSettableBenchmarkAndThresholdValues() ? TreatmentBMP.TreatmentBMPType.GetObservationTypes().First(x => x.GetHasBenchmarkAndThreshold()).BenchmarkAndThresholdUrl(treatmentBMP) : SitkaRoute <TreatmentBMPController> .BuildUrlFromExpression(x => x.Detail(treatmentBMP.TreatmentBMPTypeID)); }
public void UpdateModel(Models.TreatmentBMP treatmentBMP, Person currentPerson, DatabaseEntities databaseEntities) { // delete any assessment, benchmark, and maintenance records foreach (var maintenanceRecord in treatmentBMP.MaintenanceRecords.ToList()) { maintenanceRecord.DeleteFull(databaseEntities); } treatmentBMP.MaintenanceRecords = null; foreach (var treatmentBMPAssessment in treatmentBMP.TreatmentBMPAssessments.ToList()) { treatmentBMPAssessment.DeleteFull(databaseEntities); } treatmentBMP.TreatmentBMPAssessments = null; foreach (var treatmentBMPBenchmarkAndThreshold in treatmentBMP.TreatmentBMPBenchmarkAndThresholds.ToList()) { treatmentBMPBenchmarkAndThreshold.DeleteFull(databaseEntities); } treatmentBMP.TreatmentBMPBenchmarkAndThresholds = null; // delete any custom attributes that are not valid for the new treatment bmp type var newTreatmentBMPType = databaseEntities.TreatmentBMPTypes.GetTreatmentBMPType(TreatmentBMPTypeID.Value); var validCustomAttributeTypes = newTreatmentBMPType.TreatmentBMPTypeCustomAttributeTypes.Select(x => x.CustomAttributeTypeID); var customAttributesToDelete = treatmentBMP.CustomAttributes.Where(x => !validCustomAttributeTypes.Contains(x.CustomAttributeTypeID)) .ToList(); foreach (var customAttribute in customAttributesToDelete.ToList()) { customAttribute.DeleteFull(databaseEntities); } treatmentBMP.TreatmentBMPTypeID = TreatmentBMPTypeID.Value; }
public EditMaintenanceRecordObservationsViewData(Person currentPerson, Models.TreatmentBMP treatmentBMP, CustomAttributeTypePurpose customAttributeTypePurpose, Models.MaintenanceRecord maintenanceRecord, bool isSubForm, bool missingRequiredAttributes) : base(currentPerson, treatmentBMP, customAttributeTypePurpose, isSubForm, missingRequiredAttributes) { PageTitle = $"Edit Maintenance Record Observations"; ParentDetailUrl = maintenanceRecord.GetDetailUrl(); }
private List <HtmlString> CheckForParameterizationErrors(Models.TreatmentBMP treatmentBmp) { var parameterizationErrors = new List <HtmlString>(); if (treatmentBmp.Delineation == null && treatmentBmp.UpstreamBMP?.Delineation == null) { var linkToDelineationMapOrNot = treatmentBmp.UpstreamBMPID != null ? "Please add a BMP delineation to the Upstream BMP on the Delineation Map or remove the Upstream BMP and add a BMP delineation for this Treatment BMP." : "<a href='" + DelineationMapUrl + "'> Please add a BMP delineation on the Delineation Map</a>."; parameterizationErrors.Add(new HtmlString( "A delineation is required for each Treatment BMP to be included in Modeling or Trash result calculations. " + linkToDelineationMapOrNot)); } var hasWQMP = treatmentBmp.WaterQualityManagementPlan != null; if (hasWQMP && treatmentBmp.WaterQualityManagementPlan.WaterQualityManagementPlanModelingApproach == WaterQualityManagementPlanModelingApproach.Simplified) { var modelMissingAttributes = new HtmlString($"This BMP is associated with a {UrlTemplate.MakeHrefString(treatmentBmp.WaterQualityManagementPlan.GetDetailUrl(), "WQMP")} that is modeled using the simplified approach; this BMP will not be modeled explicitly."); parameterizationErrors.Add(modelMissingAttributes); } else { var modelMissingAttributes = new HtmlString("This Treatment BMP record is missing fields required to calculate model results. Please provide required Modeling Parameters below."); var hasMissingModelingAttributes = HasMissingModelingAttributes(); if (hasMissingModelingAttributes) { parameterizationErrors.Add(modelMissingAttributes); } } return(parameterizationErrors); }
public void UpdateModels(Person currentPerson, Models.TreatmentBMP treatmentBMP) { // Merge existing photos var photoSimples = PhotoSimples ?? new List <ManagePhotoWithPreviewPhotoSimple>(); var treatmentBMPAssessmentPhotosToUpdate = photoSimples.Select(x => x.FlagForDeletion // Exclude from list to update if flagged for deletion ? null : new Models.TreatmentBMPImage(ModelObjectHelpers.NotYetAssignedID, ModelObjectHelpers.NotYetAssignedID, DateTime.Now) { Caption = x.Caption, TreatmentBMPImageID = x.PrimaryKey }) .Where(x => x != null) .ToList(); treatmentBMP.TreatmentBMPImages.Merge(treatmentBMPAssessmentPhotosToUpdate, HttpRequestStorage.DatabaseEntities.TreatmentBMPImages.Local, (x, y) => x.TreatmentBMPImageID == y.TreatmentBMPImageID, (x, y) => { x.Caption = y.Caption; }); // Create new photo if it exists if (Photo != null) { var fileResource = FileResource.CreateNewFromHttpPostedFile(Photo, currentPerson); HttpRequestStorage.DatabaseEntities.TreatmentBMPImages.Add( new Models.TreatmentBMPImage(fileResource, treatmentBMP, DateTime.Now) { Caption = Caption }); } }
public ConvertTreatmentBMPTypeViewData(Models.TreatmentBMP treatmentBMP, IEnumerable <Models.TreatmentBMPType> treatmentBMPTypes) { TreatmentBMP = treatmentBMP; TreatmentBMPTypeSelectListItems = treatmentBMPTypes.OrderBy(x => x.TreatmentBMPTypeName) .ToSelectListWithEmptyFirstRow(x => x.TreatmentBMPTypeID.ToString(CultureInfo.InvariantCulture), y => y.TreatmentBMPTypeName); }
public SummaryForMapViewData(Person currentPerson, Models.TreatmentBMP treatmentBMP) : base(currentPerson, NeptuneArea.OCStormwaterTools) { TreatmentBMP = treatmentBMP; // we don't have the concept of a keyphoto; just arbitrarily pick the first photo KeyPhoto = treatmentBMP.TreatmentBMPImages.FirstOrDefault(); FieldVisitUrl = SitkaRoute <FieldVisitController> .BuildUrlFromExpression(x => x.New(TreatmentBMP)); UserHasFieldVisitPermissions = new FieldVisitCreateFeature().HasPermission(currentPerson, TreatmentBMP).HasPermission; }
public EditBenchmarkAndThresholdViewModel(Models.TreatmentBMP treatmentBMP, Models.TreatmentBMPAssessmentObservationType TreatmentBMPAssessmentObservationType) { TreatmentBMPID = treatmentBMP.TreatmentBMPID; TreatmentBMPAssessmentObservationTypeID = TreatmentBMPAssessmentObservationType.TreatmentBMPAssessmentObservationTypeID; var benchmarkAndThreshold = treatmentBMP.TreatmentBMPBenchmarkAndThresholds.FirstOrDefault(x => x.TreatmentBMPAssessmentObservationTypeID == TreatmentBMPAssessmentObservationType.TreatmentBMPAssessmentObservationTypeID); BenchmarkValue = benchmarkAndThreshold?.BenchmarkValue; ThresholdValue = benchmarkAndThreshold?.ThresholdValue; }
public ManageTreatmentBMPImagesViewModel(Models.TreatmentBMP treatmentBMP) { PhotoSimples = treatmentBMP.TreatmentBMPImages.Select(x => new ManagePhotoWithPreviewPhotoSimple { PrimaryKey = x.TreatmentBMPImageID, Caption = x.Caption, FlagForDeletion = false }).ToList(); }
public double?CalculateAreaWithinWQMP(Models.TreatmentBMP treatmentBMP) { if (treatmentBMP.Delineation != null && WaterQualityManagementPlan.WaterQualityManagementPlanBoundary != null && treatmentBMP.TreatmentBMPType.TreatmentBMPModelingType != null) { return(treatmentBMP.Delineation.DelineationGeometry.Intersection(WaterQualityManagementPlan .WaterQualityManagementPlanBoundary).Area *DbSpatialHelper.SquareMetersToAcres); } return(null); }
public ModeledPerformanceViewData(Models.TreatmentBMP treatmentBMP, Person person) : base(person, NeptuneArea.OCStormwaterTools) { TreatmentBMP = treatmentBMP; InflowLabel = "To BMP"; AboutModelingBMPPerformanceURL = SitkaRoute <HomeController> .BuildUrlFromExpression(x => x.AboutModelingBMPPerformance()); ModelingResultsUrl = SitkaRoute <TreatmentBMPController> .BuildUrlFromExpression(x => x.GetModelResults(treatmentBMP)); }
public ManageTreatmentBMPImagesViewData(Person currentPerson, Models.TreatmentBMP treatmentBMP, ManagePhotosWithPreviewViewData managePhotosWithPreviewViewData) : base(currentPerson, NeptuneArea.OCStormwaterTools) { TreatmentBMP = treatmentBMP; EntityName = $"{FieldDefinitionType.TreatmentBMP.GetFieldDefinitionLabelPluralized()}"; EntityUrl = SitkaRoute <TreatmentBMPController> .BuildUrlFromExpression(x => x.FindABMP()); SubEntityName = treatmentBMP.TreatmentBMPName; SubEntityUrl = treatmentBMP.GetDetailUrl(); PageTitle = "Manage Photos"; ManagePhotosWithPreviewViewData = managePhotosWithPreviewViewData; }
public NewFieldVisitViewData(Models.TreatmentBMP treatmentBMP) { FieldVisit = treatmentBMP.GetInProgressFieldVisit(); InProgressFieldVisitExists = FieldVisit != null; InProgressVisitDate = FieldVisit?.VisitDate; AllFieldVisitTypes = FieldVisitType.All.ToSelectListWithDisabledEmptyFirstRow( x => x.FieldVisitTypeID.ToString(CultureInfo.InvariantCulture), x => x.FieldVisitTypeDisplayName, "Choose a type"); }
public void UpdateModel(Models.TreatmentBMP treatmentBMP, Person currentPerson) { treatmentBMP.TreatmentBMPName = TreatmentBMPName; treatmentBMP.Notes = Notes; treatmentBMP.RequiredFieldVisitsPerYear = RequiredFieldVisitsPerYear; treatmentBMP.RequiredPostStormFieldVisitsPerYear = RequiredPostStormFieldVisitsPerYear; treatmentBMP.TrashCaptureStatusTypeID = TrashCaptureStatusTypeID.GetValueOrDefault(); // will never be null due to RequiredAttribute treatmentBMP.SizingBasisTypeID = SizingBasisTypeID.GetValueOrDefault(); // will never be null due to RequiredAttribute if (!ModelObjectHelpers.IsRealPrimaryKeyValue(treatmentBMP.TreatmentBMPID)) { treatmentBMP.StormwaterJurisdictionID = StormwaterJurisdictionID ?? ModelObjectHelpers.NotYetAssignedID; treatmentBMP.TreatmentBMPTypeID = TreatmentBMPTypeID ?? ModelObjectHelpers.NotYetAssignedID; var treatmentBMPTypeAssessmentObservationTypes = HttpRequestStorage.DatabaseEntities.TreatmentBMPTypes.Single(x => x.TreatmentBMPTypeID == TreatmentBMPTypeID).TreatmentBMPTypeAssessmentObservationTypes.Where(x => x.TreatmentBMPAssessmentObservationType.GetHasBenchmarkAndThreshold() && x.DefaultThresholdValue.HasValue && x.DefaultBenchmarkValue.HasValue); foreach (var a in treatmentBMPTypeAssessmentObservationTypes) { treatmentBMP.TreatmentBMPBenchmarkAndThresholds.Add(new Models.TreatmentBMPBenchmarkAndThreshold(treatmentBMP, a, HttpRequestStorage.DatabaseEntities.TreatmentBMPTypes.Single(x => x.TreatmentBMPTypeID == TreatmentBMPTypeID), a.TreatmentBMPAssessmentObservationType, a.DefaultBenchmarkValue ?? 0, a.DefaultThresholdValue ?? 0)); } } treatmentBMP.SystemOfRecordID = SystemOfRecordID; if (OwnerOrganizationID.HasValue) { treatmentBMP.OwnerOrganizationID = OwnerOrganizationID.Value; } else { var stormwaterJurisdiction = HttpRequestStorage.DatabaseEntities.StormwaterJurisdictions.GetStormwaterJurisdiction(treatmentBMP .StormwaterJurisdictionID); treatmentBMP.OwnerOrganizationID = stormwaterJurisdiction.OrganizationID; } treatmentBMP.YearBuilt = YearBuilt; treatmentBMP.WaterQualityManagementPlanID = WaterQualityManagementPlanID; treatmentBMP.TreatmentBMPLifespanTypeID = TreatmentBMPLifespanTypeID; treatmentBMP.TreatmentBMPLifespanEndDate = TreatmentBMPLifespanTypeID == TreatmentBMPLifespanType.FixedEndDate.TreatmentBMPLifespanTypeID ? TreatmentBMPLifespanEndDate : null; treatmentBMP.TrashCaptureEffectiveness = TrashCaptureStatusTypeID == TrashCaptureStatusType.Partial.TrashCaptureStatusTypeID ? TrashCaptureEffectiveness : null; }
public NewViewData(Person currentPerson, Models.TreatmentBMP treatmentBMP, RegionalSubbasinRevisionRequestMapInitJson mapInitJson) : base(currentPerson, NeptuneArea.OCStormwaterTools) { TreatmentBMP = treatmentBMP; MapInitJson = mapInitJson; GeoServerUrl = NeptuneWebConfiguration.ParcelMapServiceUrl; MapFormID = "revisionRequestHiddenInputContainer"; SubmitUrl = SitkaRoute <RegionalSubbasinRevisionRequestController> .BuildUrlFromExpression(x => x.New(treatmentBMP)); EntityName = "Regional Subbasin"; EntityUrl = SitkaRoute <RegionalSubbasinRevisionRequestController> .BuildUrlFromExpression(x => x.Index()); PageTitle = "Revision"; ExistingOpenRequest = treatmentBMP.RegionalSubbasinRevisionRequests.SingleOrDefault(x => x.RegionalSubbasinRevisionRequestStatusID == RegionalSubbasinRevisionRequestStatus.Open.RegionalSubbasinRevisionRequestStatusID); }
private BenchmarkAndThresholdViewData(Person currentPerson, Models.TreatmentBMP treatmentBMP, string sectionName) : base(currentPerson, NeptuneArea.OCStormwaterTools) { TreatmentBMP = treatmentBMP; InstructionsUrl = SitkaRoute <TreatmentBMPBenchmarkAndThresholdController> .BuildUrlFromExpression(x => x.Instructions(treatmentBMP.TreatmentBMPID)); SectionName = sectionName; EntityName = FieldDefinitionType.TreatmentBMP.GetFieldDefinitionLabelPluralized(); EntityUrl = SitkaRoute <TreatmentBMPController> .BuildUrlFromExpression(x => x.FindABMP()); SubEntityName = treatmentBMP.TreatmentBMPName; SubEntityUrl = treatmentBMP.GetDetailUrl(); PageTitle = "Benchmark & Threshold"; }
public WaterQualityManagementPlanVerifyTreatmentBMPSimple(Models.TreatmentBMP treatmentBMP) { WaterQualityManagementPlanVerifyTreatmentBMPID = null; TreatmentBMPName = treatmentBMP.TreatmentBMPName; TreatmentBMPID = treatmentBMP.TreatmentBMPID; IsAdequate = null; WaterQualityManagementPlanVerifyTreatmentBMPNote = null; TreatmentBMPType = treatmentBMP.TreatmentBMPType.TreatmentBMPTypeName; var mostRecentFieldVisit = treatmentBMP.FieldVisits.Where(x => x.FieldVisitStatus == FieldVisitStatus.Complete).OrderBy(x => x.VisitDate).FirstOrDefault(); FieldVisiLastVisitedtDate = mostRecentFieldVisit?.VisitDate.ToShortDateString(); FieldVisitMostRecentScore = mostRecentFieldVisit?.GetPostMaintenanceAssessment() != null?mostRecentFieldVisit.GetPostMaintenanceAssessment().FormattedScore() : mostRecentFieldVisit?.GetInitialAssessment().FormattedScore(); TreatmentBMPDetailUrl = SitkaRoute <TreatmentBMPController> .BuildUrlFromExpression(c => c.Detail(treatmentBMP.PrimaryKey)); }
public EditMaintenanceRecordViewData(Person currentPerson, List <Models.Organization> organizations, Models.TreatmentBMP treatmentBMP, bool isNew, Models.FieldVisit fieldVisit, EditAttributesViewData editMaintenanceRecordObservationsViewData) : base(currentPerson, fieldVisit, Models.FieldVisitSection.Maintenance) { SubsectionName = "Edit Maintenance Record"; IsNew = isNew; EditMaintenanceRecordObservationsViewData = editMaintenanceRecordObservationsViewData; AllOrganizations = organizations.OrderBy(x => x.OrganizationName).ToSelectListWithDisabledEmptyFirstRow(x => x.OrganizationID.ToString(CultureInfo.InvariantCulture), x => x.OrganizationName, "Choose an Organization"); AllMaintenanceRecordTypes = MaintenanceRecordType.All.ToSelectListWithDisabledEmptyFirstRow( x => x.MaintenanceRecordTypeID.ToString(CultureInfo.InvariantCulture), x => x.MaintenanceRecordTypeDisplayName, "Choose a type"); TreatmentBMPUrl = treatmentBMP.GetDetailUrl(); MaintenanceRecordUrl = MaintenanceRecord?.GetDetailUrl(); }
public virtual void UpdateModel(Models.TreatmentBMP treatmentBMP, Person currentPerson) { // note that these nullables will never be null due to the Required attribute // this is coming FROM the browser, so it has to be reprojected to CA State Plane var locationPoint4326 = DbSpatialHelper.MakeDbGeometryFromCoordinates(TreatmentBMPPointX.GetValueOrDefault(), TreatmentBMPPointY.GetValueOrDefault(), CoordinateSystemHelper.WGS_1984_SRID); var locationPoint = CoordinateSystemHelper.ProjectWebMercatorToCaliforniaStatePlaneVI(locationPoint4326); treatmentBMP.LocationPoint = locationPoint; treatmentBMP.LocationPoint4326 = locationPoint4326; treatmentBMP.UpdateUpstreamBMPReferencesIfNecessary(); // associate watershed, lspc basin, precipitation zone treatmentBMP.SetTreatmentBMPPointInPolygonDataByLocationPoint(locationPoint); treatmentBMP.UpdatedCentralizedBMPDelineationIfPresent(); }
public EditViewModel(Models.TreatmentBMP treatmentBMP) { TreatmentBMPID = treatmentBMP.TreatmentBMPID; TreatmentBMPName = treatmentBMP.TreatmentBMPName; StormwaterJurisdictionID = treatmentBMP.StormwaterJurisdictionID; TreatmentBMPTypeID = treatmentBMP.TreatmentBMPTypeID; Notes = treatmentBMP.Notes; SystemOfRecordID = treatmentBMP.SystemOfRecordID; OwnerOrganizationID = treatmentBMP.OwnerOrganizationID; YearBuilt = treatmentBMP.YearBuilt; WaterQualityManagementPlanID = treatmentBMP.WaterQualityManagementPlanID; TreatmentBMPLifespanTypeID = treatmentBMP.TreatmentBMPLifespanTypeID; TreatmentBMPLifespanEndDate = treatmentBMP.TreatmentBMPLifespanEndDate; RequiredFieldVisitsPerYear = treatmentBMP.RequiredFieldVisitsPerYear; RequiredPostStormFieldVisitsPerYear = treatmentBMP.RequiredPostStormFieldVisitsPerYear; TrashCaptureStatusTypeID = treatmentBMP.TrashCaptureStatusTypeID; SizingBasisTypeID = treatmentBMP.SizingBasisTypeID; TrashCaptureEffectiveness = treatmentBMP.TrashCaptureEffectiveness; }
public EditAttributesViewData(Person currentPerson, Models.TreatmentBMP treatmentBMP, CustomAttributeTypePurpose customAttributeTypePurpose, bool isSubForm, bool missingRequiredAttributes) : base(currentPerson, NeptuneArea.OCStormwaterTools) { IsSubForm = isSubForm; MissingRequiredAttributes = missingRequiredAttributes; EntityName = $"{FieldDefinitionType.TreatmentBMP.GetFieldDefinitionLabelPluralized()}"; var treatmentBMPIndexUrl = SitkaRoute <TreatmentBMPController> .BuildUrlFromExpression(x => x.FindABMP()); EntityUrl = treatmentBMPIndexUrl; SubEntityName = treatmentBMP.TreatmentBMPName; SubEntityUrl = treatmentBMP.GetDetailUrl(); PageTitle = $"Edit {FieldDefinitionType.TreatmentBMP.GetFieldDefinitionLabel()} Attributes"; ParentDetailUrl = treatmentBMP.GetDetailUrl(); TreatmentBMPTypeCustomAttributeTypes = treatmentBMP.TreatmentBMPType.TreatmentBMPTypeCustomAttributeTypes .Where(x => x.CustomAttributeType.CustomAttributeTypePurposeID == customAttributeTypePurpose.CustomAttributeTypePurposeID) .ToList().SortByOrderThenName().ToList(); }
private List <HtmlString> CheckForDelineationErrors(Models.TreatmentBMP treatmentBMP) { var delineationErrors = new List <HtmlString>(); var delineationHasDiscrepancies = TreatmentBMP.Delineation?.HasDiscrepancies ?? false; if (delineationHasDiscrepancies) { delineationErrors.Add(new HtmlString("It is not consistent with the most recent Regional Subbasin Layer.")); } if (treatmentBMP.Delineation != null && treatmentBMP.Delineation.DelineationOverlaps.Any()) { delineationErrors.Add(new HtmlString("It is overlapping with the following Treatment BMP(s): " + string.Join(", ", treatmentBMP.Delineation.DelineationOverlaps.Select(x => x.OverlappingDelineation.TreatmentBMP.GetDisplayNameAsUrl())))); } return(delineationErrors); }
public EditModelingAttributesViewData(Person currentPerson, Models.TreatmentBMP treatmentBMP, IEnumerable <RoutingConfiguration> routingConfigurations, IEnumerable <TimeOfConcentration> timeOfConcentrations, IEnumerable <UnderlyingHydrologicSoilGroup> underlyingHydrologicSoilGroups, List <MonthsOfOperation> monthsOfOperation, List <DryWeatherFlowOverride> dryWeatherFlowOverride) : base(currentPerson, NeptuneArea.OCStormwaterTools) { EntityName = $"{FieldDefinitionType.TreatmentBMP.GetFieldDefinitionLabelPluralized()}"; EntityUrl = SitkaRoute <TreatmentBMPController> .BuildUrlFromExpression(x => x.FindABMP()); SubEntityName = treatmentBMP.TreatmentBMPName; SubEntityUrl = treatmentBMP.GetDetailUrl(); PageTitle = $"Edit {FieldDefinitionType.TreatmentBMP.GetFieldDefinitionLabel()} Modeling Attributes"; TreatmentBMP = treatmentBMP; DryWeatherFlowOverride = dryWeatherFlowOverride.ToSelectList(x => x.DryWeatherFlowOverrideID.ToString(), x => x.DryWeatherFlowOverrideDisplayName); MonthsOfOperation = monthsOfOperation.ToSelectList(x => x.MonthsOfOperationID.ToString(CultureInfo.InvariantCulture), x => x.MonthsOfOperationDisplayName); UnderlyingHydrologicSoilGroups = underlyingHydrologicSoilGroups.ToSelectListWithEmptyFirstRow(x => x.UnderlyingHydrologicSoilGroupID.ToString(), x => x.UnderlyingHydrologicSoilGroupDisplayName); TimeOfConcentrations = timeOfConcentrations.ToSelectListWithEmptyFirstRow(x => x.TimeOfConcentrationID.ToString(), x => $"{x.TimeOfConcentrationDisplayName} minutes"); RoutingConfigurations = routingConfigurations.ToSelectListWithEmptyFirstRow(x => x.RoutingConfigurationID.ToString(), x => x.RoutingConfigurationDisplayName); }
public NewViewData(Person currentPerson, Models.TreatmentBMP treatmentBMP, IEnumerable <StormwaterJurisdiction> stormwaterJurisdictions, IEnumerable <Models.TreatmentBMPType> treatmentBMPTypes, List <Models.Organization> organizations, Shared.Location.EditLocationViewData editLocationViewData, IEnumerable <Models.WaterQualityManagementPlan> waterQualityManagementPlans, IEnumerable <TreatmentBMPLifespanType> treatmentBMPLifespanTypes, IEnumerable <TrashCaptureStatusType> trashCaptureStatusTypes, IEnumerable <SizingBasisType> sizingBasisTypes) : base(currentPerson, NeptuneArea.OCStormwaterTools) { EditLocationViewData = editLocationViewData; SizingBasisTypes = sizingBasisTypes.ToSelectListWithDisabledEmptyFirstRow( x => x.SizingBasisTypeID.ToString(CultureInfo.InvariantCulture), x => x.SizingBasisTypeDisplayName.ToString(CultureInfo.InvariantCulture)); EntityName = $"{FieldDefinitionType.TreatmentBMP.GetFieldDefinitionLabelPluralized()}"; var treatmentBMPIndexUrl = SitkaRoute <TreatmentBMPController> .BuildUrlFromExpression(x => x.FindABMP()); EntityUrl = treatmentBMPIndexUrl; if (treatmentBMP != null) { SubEntityName = treatmentBMP.TreatmentBMPName; SubEntityUrl = treatmentBMP.GetDetailUrl(); TreatmentBMP = treatmentBMP; } PageTitle = $"New {FieldDefinitionType.TreatmentBMP.GetFieldDefinitionLabel()}"; TrashCaptureStatusTypes = trashCaptureStatusTypes.ToSelectListWithDisabledEmptyFirstRow( x => x.TrashCaptureStatusTypeID.ToString(CultureInfo.InvariantCulture), x => x.TrashCaptureStatusTypeDisplayName.ToString(CultureInfo.InvariantCulture)); StormwaterJurisdictionSelectListItems = stormwaterJurisdictions.OrderBy(x => x.GetOrganizationDisplayName()).ToSelectListWithEmptyFirstRow(x => x.StormwaterJurisdictionID.ToString(CultureInfo.InvariantCulture), y => y.GetOrganizationDisplayName()); TreatmentBMPTypeSelectListItems = treatmentBMPTypes.OrderBy(x => x.TreatmentBMPTypeName).ToSelectListWithEmptyFirstRow(x => x.TreatmentBMPTypeID.ToString(CultureInfo.InvariantCulture), y => y.TreatmentBMPTypeName); OwnerOrganizationSelectListItems = organizations.OrderBy(x => x.GetDisplayName()).ToSelectListWithEmptyFirstRow(x => x.OrganizationID.ToString(CultureInfo.InvariantCulture), y => y.GetDisplayName(), "Same as the BMP Jurisdiction"); TreatmentBMPIndexUrl = treatmentBMPIndexUrl; WaterQualityManagementPlanSelectListItems = BuildWaterQualityPlanSelectList(waterQualityManagementPlans); TreatmentBMPLifespanTypes = treatmentBMPLifespanTypes.ToSelectListWithEmptyFirstRow( x => x.TreatmentBMPLifespanTypeID.ToString(CultureInfo.InvariantCulture), x => x.TreatmentBMPLifespanTypeDisplayName.ToString(CultureInfo.InvariantCulture), "Unknown"); }
public void UpdateModel(Models.TreatmentBMP treatmentBMP, Person currentPerson, CustomAttributeTypePurpose customAttributeTypePurpose, List <Models.CustomAttributeType> allCustomAttributeTypes) { var customAttributeSimplesWithValues = CustomAttributes.Where(x => x.CustomAttributeValues != null && x.CustomAttributeValues.Count > 0); var customAttributesToUpdate = new List <CustomAttribute>(); var customAttributeValuesToUpdate = new List <CustomAttributeValue>(); foreach (var x in customAttributeSimplesWithValues) { var customAttribute = new CustomAttribute(treatmentBMP.TreatmentBMPID, x.TreatmentBMPTypeCustomAttributeTypeID, treatmentBMP.TreatmentBMPTypeID, x.CustomAttributeTypeID); customAttributesToUpdate.Add(customAttribute); foreach (var value in x.CustomAttributeValues) { var valueParsedForDataType = allCustomAttributeTypes.Single(y => y.CustomAttributeTypeID == x.CustomAttributeTypeID).CustomAttributeDataType.ValueParsedForDataType(value); var customAttributeValue = new CustomAttributeValue(customAttribute, valueParsedForDataType); customAttributeValuesToUpdate.Add(customAttributeValue); } } var customAttributesInDatabase = HttpRequestStorage.DatabaseEntities.CustomAttributes.Local; var customAttributeValuesInDatabase = HttpRequestStorage.DatabaseEntities.CustomAttributeValues.Local; var existingCustomAttributes = treatmentBMP.CustomAttributes.Where(x => x.CustomAttributeType.CustomAttributeTypePurposeID == customAttributeTypePurpose.CustomAttributeTypePurposeID).ToList(); var existingCustomAttributeValues = existingCustomAttributes.SelectMany(x => x.CustomAttributeValues).ToList(); existingCustomAttributes.Merge(customAttributesToUpdate, customAttributesInDatabase, (x, y) => x.TreatmentBMPID == y.TreatmentBMPID && x.TreatmentBMPTypeID == y.TreatmentBMPTypeID && x.CustomAttributeTypeID == y.CustomAttributeTypeID && x.CustomAttributeID == y.CustomAttributeID); existingCustomAttributeValues.Merge(customAttributeValuesToUpdate, customAttributeValuesInDatabase, (x, y) => x.CustomAttributeValueID == y.CustomAttributeValueID && x.CustomAttributeID == y.CustomAttributeID, (x, y) => { x.AttributeValue = y.AttributeValue; }); }
private static void SendRSBRevisionRequestSubmittedEmail(Models.Person requestPerson, Models.TreatmentBMP requestBMP, RegionalSubbasinRevisionRequest request) { var subject = $"A new Regional Subbasin Revision Request was submitted"; var firstName = requestPerson.FirstName; var lastName = requestPerson.LastName; var organizationName = requestPerson.Organization.OrganizationName; var bmpName = requestBMP.TreatmentBMPName; var requestDetails = request.GetDetailUrl(); var requestPersonEmail = requestPerson.Email; var message = $@" <div style='font-size: 12px; font-family: Arial'> <strong>{subject}</strong><br /> <br /> A new Regional Subbasin Revision Request was just submitted by {firstName} {lastName} ({organizationName}) for BMP {bmpName}. Please review it, make revisions, and close it at your earliest convenience. <a href='{requestDetails}'>View this Request</a> <div>You received this email because you are assigned to receive Regional Subbasin Revision Request notifications within the Orange County Stormwater Tools. </div>. </div> "; // Create Notification var mailMessage = new MailMessage { From = new MailAddress(Common.NeptuneWebConfiguration.DoNotReplyEmail), Subject = subject, Body = message, IsBodyHtml = true }; mailMessage.CC.Add(requestPersonEmail); foreach (var revisionRequestPeople in HttpRequestStorage.DatabaseEntities.People .GetPeopleWhoReceiveRSBRevisionRequests()) { mailMessage.To.Add(revisionRequestPeople.Email); } SitkaSmtpClient.Send(mailMessage); }
public EditLocationViewData(Person currentPerson, Models.TreatmentBMP treatmentBMP, MapInitJson mapInitJson, string mapFormID) : base(currentPerson, NeptuneArea.OCStormwaterTools) { EntityName = $"{FieldDefinitionType.TreatmentBMP.GetFieldDefinitionLabelPluralized()}"; var treatmentBMPIndexUrl = SitkaRoute <TreatmentBMPController> .BuildUrlFromExpression(x => x.FindABMP()); EntityUrl = treatmentBMPIndexUrl; if (treatmentBMP != null) { SubEntityName = treatmentBMP.TreatmentBMPName; SubEntityUrl = treatmentBMP.GetDetailUrl(); TreatmentBMP = treatmentBMP; } PageTitle = "Edit Location"; MapInitJson = mapInitJson; MapFormID = mapFormID; TreatmentBMPInformationContainer = $"{mapInitJson.MapDivID}LocationInformationContainer"; }
public EditBenchmarkAndThresholdViewData(Person currentPerson, Models.TreatmentBMP treatmentBMP, Models.TreatmentBMPAssessmentObservationType TreatmentBMPAssessmentObservationType) : base(currentPerson, treatmentBMP, TreatmentBMPAssessmentObservationType) { BenchmarkMeasurementUnitTypeDisplayName = TreatmentBMPAssessmentObservationType.BenchmarkMeasurementUnitType().MeasurementUnitTypeDisplayName; ThresholdMeasurementUnitTypeDisplayName = TreatmentBMPAssessmentObservationType.ThresholdMeasurementUnitType().MeasurementUnitTypeDisplayName; BenchmarkMeasurementUnitLabel = TreatmentBMPAssessmentObservationType.BenchmarkMeasurementUnitLabel(); ThresholdMeasurementUnitLabel = TreatmentBMPAssessmentObservationType.ThresholdMeasurementUnitLabel(); BenchmarkDescription = TreatmentBMPAssessmentObservationType.BenchmarkDescription(); ThresholdDescription = TreatmentBMPAssessmentObservationType.ThresholdDescription(); var TreatmentBMPTypeAssessmentObservationType = treatmentBMP.TreatmentBMPType.GetTreatmentBMPTypeObservationType(TreatmentBMPAssessmentObservationType); DefaultBenchmarkPlaceholder = TreatmentBMPTypeAssessmentObservationType.DefaultBenchmarkValue.HasValue ? "default is " + TreatmentBMPTypeAssessmentObservationType.DefaultBenchmarkValue.Value : string.Empty; DefaultBenchmarkText = TreatmentBMPTypeAssessmentObservationType.DefaultBenchmarkValue.HasValue ? $"The default value is {TreatmentBMPTypeAssessmentObservationType.DefaultBenchmarkValue} {TreatmentBMPAssessmentObservationType.BenchmarkMeasurementUnitType().MeasurementUnitTypeDisplayName}." : string.Empty; DefaultThresholdPlaceholder = TreatmentBMPTypeAssessmentObservationType.DefaultThresholdValue.HasValue ? "default is " + TreatmentBMPTypeAssessmentObservationType.DefaultThresholdValue.Value : string.Empty; TargetIsSweetSpot = TreatmentBMPAssessmentObservationType.GetTargetIsSweetSpot(); var optionalPlusMinus = TreatmentBMPAssessmentObservationType.GetTargetIsSweetSpot() ? "+/-" : ""; DefaultThresholdText = TreatmentBMPTypeAssessmentObservationType.DefaultThresholdValue.HasValue ? $"The default value is {optionalPlusMinus} {TreatmentBMPTypeAssessmentObservationType.DefaultThresholdValue} {TreatmentBMPAssessmentObservationType.ThresholdMeasurementUnitType().MeasurementUnitTypeDisplayName}." : string.Empty; }
public string DisplayDryWeatherFlowOverride(Models.TreatmentBMP treatmentBMP) { return(treatmentBMP.TreatmentBMPModelingAttribute != null ? treatmentBMP.TreatmentBMPModelingAttribute?.DryWeatherFlowOverride?.DryWeatherFlowOverrideDisplayName : DryWeatherFlowOverride.No.DryWeatherFlowOverrideDisplayName); }