public ViewResult ManageTreatmentBMPImages(TreatmentBMPPrimaryKey treatmentBMPPrimaryKey) { var treatmentBMP = treatmentBMPPrimaryKey.EntityObject; var viewModel = new ManageTreatmentBMPImagesViewModel(treatmentBMP); return(ViewManageTreatmentBMPImages(viewModel, treatmentBMP)); }
public PartialViewResult NewFundingEvent(TreatmentBMPPrimaryKey treatmentBMPPrimaryKey) { var treatmentBMP = treatmentBMPPrimaryKey.EntityObject; var viewModel = new EditViewModel(treatmentBMP); return(ViewNewFundingEventFundingSources(viewModel, treatmentBMP)); }
public JsonResult ValidateTreatmentFacility(TreatmentBMPPrimaryKey treatmentBMPPrimaryKey) { var treatmentFacilityUrl = $"{NeptuneWebConfiguration.NereidUrl}/api/v1/treatment_facility/validate?state=ca®ion=soc"; var treatmentFacility = treatmentBMPPrimaryKey.EntityObject.ToTreatmentFacility(true); var treatmentFacilityTable = new TreatmentFacilityTable() { TreatmentFacilities = new List <TreatmentFacility> { treatmentFacility } }; var stopwatch = new Stopwatch(); stopwatch.Start(); NereidUtilities.RunJobAtNereid <TreatmentFacilityTable, object>(treatmentFacilityTable, treatmentFacilityUrl, out var responseContent, HttpClient); var stopwatchElapsedMilliseconds = stopwatch.ElapsedMilliseconds; return(Json( new { rpcTime = stopwatchElapsedMilliseconds, responseContent, requestContent = JsonConvert.SerializeObject(treatmentFacilityTable) }, JsonRequestBehavior.AllowGet)); }
public ViewResult Instructions(TreatmentBMPPrimaryKey treatmentBMPPrimaryKey) { var treatmentBMP = treatmentBMPPrimaryKey.EntityObject; var viewData = new InstructionsViewData(CurrentPerson, treatmentBMP); return(RazorView <Instructions, InstructionsViewData>(viewData)); }
public PartialViewResult TrashMapAssetPanel(TreatmentBMPPrimaryKey treatmentBMPPrimaryKey) { var treatmentBMP = treatmentBMPPrimaryKey.EntityObject; var viewData = new TrashMapAssetPanelViewData(CurrentPerson, treatmentBMP); return(RazorPartialView <TrashMapAssetPanel, TrashMapAssetPanelViewData>(viewData)); }
public ContentResult UpstreamDelineation(TreatmentBMPPrimaryKey treatmentBMPPrimaryKey) { var dbGeometry = treatmentBMPPrimaryKey.EntityObject.GetCentralizedDelineationGeometry4326(HttpRequestStorage.DatabaseEntities); var feature = DbGeometryToGeoJsonHelper.FromDbGeometryWithNoReproject(dbGeometry); return(Content(JObject.FromObject(feature).ToString(Formatting.None))); }
public ViewResult New(TreatmentBMPPrimaryKey treatmentBMPPrimaryKey) { var treatmentBMP = treatmentBMPPrimaryKey.EntityObject; var viewModel = new NewViewModel(); return(ViewNew(viewModel, treatmentBMP)); }
public ViewResult EditBenchmarkAndThreshold(TreatmentBMPPrimaryKey treatmentBMPPrimaryKey, TreatmentBMPAssessmentObservationTypePrimaryKey treatmentBMPAssessmentObservationTypePrimaryKey) { var treatmentBMP = treatmentBMPPrimaryKey.EntityObject; var TreatmentBMPAssessmentObservationType = treatmentBMPAssessmentObservationTypePrimaryKey.EntityObject; var viewModel = new EditBenchmarkAndThresholdViewModel(treatmentBMP, TreatmentBMPAssessmentObservationType); return(ViewEditBenchmarkAndThreshold(treatmentBMP, TreatmentBMPAssessmentObservationType, viewModel)); }
public ActionResult New(TreatmentBMPPrimaryKey treatmentBMPPrimaryKey, NewViewModel viewModel) { var treatmentBMP = treatmentBMPPrimaryKey.EntityObject; if (!ModelState.IsValid) { return(ViewNewTreatmentBMPDocument(viewModel)); } var treatmentBMPDocument = new TreatmentBMPDocument(treatmentBMP); viewModel.UpdateModel(treatmentBMPDocument, CurrentPerson); HttpRequestStorage.DatabaseEntities.TreatmentBMPDocuments.Add(treatmentBMPDocument); return(new ModalDialogFormJsonResult()); }
public ActionResult ManageTreatmentBMPImages(TreatmentBMPPrimaryKey treatmentBMPPrimaryKey, ManageTreatmentBMPImagesViewModel viewModel) { var treatmentBMP = treatmentBMPPrimaryKey.EntityObject; if (!ModelState.IsValid) { return(ViewManageTreatmentBMPImages(viewModel, treatmentBMP)); } treatmentBMP.MarkInventoryAsProvisionalIfNonManager(CurrentPerson); viewModel.UpdateModels(CurrentPerson, treatmentBMP); SetMessageForDisplay("Successfully updated treatment BMP assessment photos."); return(Redirect( SitkaRoute <TreatmentBMPImageController> .BuildUrlFromExpression(c => c.ManageTreatmentBMPImages(treatmentBMP)))); }
public ActionResult EditBenchmarkAndThreshold(TreatmentBMPPrimaryKey treatmentBMPPrimaryKey, TreatmentBMPAssessmentObservationTypePrimaryKey treatmentBMPAssessmentObservationTypePrimaryKey, EditBenchmarkAndThresholdViewModel viewModel) { var treatmentBMP = treatmentBMPPrimaryKey.EntityObject; var treatmentBMPAssessmentObservationType = treatmentBMPAssessmentObservationTypePrimaryKey.EntityObject; if (!ModelState.IsValid) { SetErrorForDisplay("Could not save benchmark and threshold values: Please fix validation errors to proceed."); return(ViewEditBenchmarkAndThreshold(treatmentBMP, treatmentBMPAssessmentObservationType, viewModel)); } var benchmarkAndThreshold = GetExistingTreatmentBMPObservationOrCreateNew(treatmentBMP, treatmentBMPAssessmentObservationType); viewModel.UpdateModel(benchmarkAndThreshold, CurrentPerson); SetMessageForDisplay("Benchmark and threshold values successfully saved."); return(viewModel.AutoAdvance ? GetNextObservationTypeViewResult(treatmentBMP, treatmentBMPAssessmentObservationType) : RedirectToAction(new SitkaRoute <TreatmentBMPBenchmarkAndThresholdController>(c => c.EditBenchmarkAndThreshold(treatmentBMPPrimaryKey, treatmentBMPAssessmentObservationTypePrimaryKey)))); }
public ContentResult ForTreatmentBMP(TreatmentBMPPrimaryKey treatmentBMPPrimaryKey) { var treatmentBMP = treatmentBMPPrimaryKey.EntityObject; if (treatmentBMP.Delineation == null) { // should be 400 tbh return(Content(JObject.FromObject(new { noDelineation = true }).ToString(Formatting.None))); } var feature = DbGeometryToGeoJsonHelper.FromDbGeometryWithNoReproject(treatmentBMP.Delineation.DelineationGeometry4326); feature.Properties.Add("Area", treatmentBMP.GetDelineationAreaString()); feature.Properties.Add("DelineationType", treatmentBMP.Delineation?.DelineationType.DelineationTypeDisplayName ?? "No delineation provided"); feature.Properties.Add("DelineationStatus", treatmentBMP.Delineation?.IsVerified ?? false ? "Verified" : "Provisional"); return(Content(JObject.FromObject(feature).ToString(Formatting.None))); }
public ActionResult New(TreatmentBMPPrimaryKey treatmentBMPPrimaryKey, NewViewModel viewModel) { var treatmentBMP = treatmentBMPPrimaryKey.EntityObject; var openRequest = treatmentBMP.RegionalSubbasinRevisionRequests.SingleOrDefault(x => x.RegionalSubbasinRevisionRequestStatusID == RegionalSubbasinRevisionRequestStatus.Open.RegionalSubbasinRevisionRequestStatusID); Check.Assert(openRequest == null, "You cannot open a new revision request for this BMP because there is already an open revision request."); if (!ModelState.IsValid) { return(ViewNew(viewModel, treatmentBMP)); } var dbGeometrys = viewModel.WktAndAnnotations.Select(x => DbGeometry.FromText(x.Wkt, CoordinateSystemHelper.WGS_1984_SRID).ToSqlGeometry().MakeValid() .ToDbGeometry()); var unionListGeometries = dbGeometrys.ToList().UnionListGeometries().FixSrid(CoordinateSystemHelper.WGS_1984_SRID); var regionalSubbasinRevisionRequest = new RegionalSubbasinRevisionRequest( treatmentBMPPrimaryKey.PrimaryKeyValue, unionListGeometries, CurrentPerson.PersonID, RegionalSubbasinRevisionRequestStatus.Open.RegionalSubbasinRevisionRequestStatusID, DateTime.Now) { Notes = viewModel.Notes }; HttpRequestStorage.DatabaseEntities.RegionalSubbasinRevisionRequests.Add(regionalSubbasinRevisionRequest); HttpRequestStorage.DatabaseEntities.SaveChanges(); SendRSBRevisionRequestSubmittedEmail(CurrentPerson, treatmentBMP, regionalSubbasinRevisionRequest); SetMessageForDisplay("Successfully submitted the Regional Subbasin Revision Request"); return(RedirectToAction( new SitkaRoute <RegionalSubbasinRevisionRequestController>( x => x.Detail(regionalSubbasinRevisionRequest)))); }
public ActionResult NewFundingEvent(TreatmentBMPPrimaryKey treatmentBMPPrimaryKey, EditViewModel viewModel) { var treatmentBMP = treatmentBMPPrimaryKey.EntityObject; if (!ModelState.IsValid) { return(ViewNewFundingEventFundingSources(viewModel, treatmentBMP)); } var fundingEvent = new FundingEvent(treatmentBMPPrimaryKey.EntityObject.TreatmentBMPID, viewModel.FundingEvent.FundingEventTypeID, viewModel.FundingEvent.Year) { FundingEventFundingSources = viewModel.FundingEvent.FundingEventFundingSources? .Select(x => x.ToFundingEventFundingSource()).ToList(), Description = viewModel.FundingEvent.Description }; HttpRequestStorage.DatabaseEntities.FundingEvents.Add(fundingEvent); HttpRequestStorage.DatabaseEntities.SaveChanges(); SetMessageForDisplay($"{FieldDefinitionType.FundingEvent.GetFieldDefinitionLabel()} successfully added."); return(new ModalDialogFormJsonResult()); }
public ActionResult MapDelete(TreatmentBMPPrimaryKey treatmentBMPPrimaryKey, MapDeleteViewModel viewModel) { var treatmentBMP = treatmentBMPPrimaryKey.EntityObject; var delineation = treatmentBMP.Delineation; var isDelineationDistributed = delineation?.DelineationType == DelineationType.Distributed; var geometry = delineation?.DelineationGeometry; if (delineation == null) { throw new SitkaRecordNotFoundException( $"No delineation found for Treatment BMP {treatmentBMPPrimaryKey}"); } delineation.DeleteDelineation(HttpRequestStorage.DatabaseEntities); if (isDelineationDistributed) { ModelingEngineUtilities.QueueLGURefreshForArea(geometry, null); } SetMessageForDisplay("The Delineation was successfully deleted."); return(Json(new { success = true })); }
public ActionResult ForTreatmentBMP(TreatmentBMPPrimaryKey treatmentBMPPrimaryKey, ForTreatmentBMPViewModel viewModel) { if (!Enum.TryParse(viewModel.DelineationType, out DelineationTypeEnum delineationTypeEnum)) { // todo: really should return a 400 bad request return(Json(new { error = "Invalid Delineation Type" })); } DbGeometry geom4326; if (viewModel.WellKnownText.Count == 1) { geom4326 = viewModel.WellKnownText[0] == DbGeometryToGeoJsonHelper.POLYGON_EMPTY ? null : DbGeometry.FromText(viewModel.WellKnownText[0], CoordinateSystemHelper.WGS_1984_SRID).ToSqlGeometry() .MakeValid().ToDbGeometry().FixSrid(CoordinateSystemHelper.WGS_1984_SRID); } else { geom4326 = viewModel.WellKnownText .Select(x => DbGeometry.FromText(x, CoordinateSystemHelper.WGS_1984_SRID).ToSqlGeometry().MakeValid() .ToDbGeometry().FixSrid(CoordinateSystemHelper.WGS_1984_SRID)).ToList() .UnionListGeometries(); } DbGeometry geom2771 = null; // like all POSTs from the browser, transform to State Plane if (geom4326 != null) { geom2771 = CoordinateSystemHelper.ProjectWebMercatorToCaliforniaStatePlaneVI(geom4326); } var treatmentBMP = treatmentBMPPrimaryKey.EntityObject; var treatmentBMPDelineation = treatmentBMP.Delineation; // for queueing the LGU job var newShape = geom2771; var oldShape = treatmentBMPDelineation?.DelineationGeometry; var delineationType = DelineationType.ToType(delineationTypeEnum); if (treatmentBMPDelineation != null) { if (geom4326 != null) { treatmentBMPDelineation.DelineationGeometry = geom2771; treatmentBMPDelineation.DelineationGeometry4326 = geom4326; treatmentBMPDelineation.DelineationTypeID = delineationType.DelineationTypeID; treatmentBMPDelineation.IsVerified = false; treatmentBMPDelineation.DateLastModified = DateTime.Now; } else { treatmentBMPDelineation.DeleteDelineation(HttpRequestStorage.DatabaseEntities); } } else { if (geom4326 == null) { return(Json(new { success = true })); } var delineation = new Delineation(geom2771, delineationType.DelineationTypeID, false, treatmentBMP.TreatmentBMPID, DateTime.Now, false) { DelineationGeometry4326 = geom4326 }; HttpRequestStorage.DatabaseEntities.Delineations.Add(delineation); } HttpRequestStorage.DatabaseEntities.SaveChanges(); if (!(newShape == null & oldShape == null) && treatmentBMP.TreatmentBMPType.TreatmentBMPModelingType != null) { ModelingEngineUtilities.QueueLGURefreshForArea(oldShape, newShape); } return(Json(new { success = true, delineationID = treatmentBMP.Delineation.DelineationID })); }
public ContentResult MapDelete(TreatmentBMPPrimaryKey treatmentBMPPrimaryKey) { return(new ContentResult()); }
public ActionResult New(TreatmentBMPPrimaryKey treatmentBMPPrimaryKey) { var viewModel = new NewViewModel(); return(ViewNewTreatmentBMPDocument(viewModel)); }