public ActionResult EditWqmpParcels(WaterQualityManagementPlanPrimaryKey waterQualityManagementPlanPrimaryKey, EditWqmpParcelsViewModel viewModel) { var waterQualityManagementPlan = waterQualityManagementPlanPrimaryKey.EntityObject; if (!ModelState.IsValid) { return(ViewEditWqmpParcels(waterQualityManagementPlan, viewModel)); } var oldBoundary = waterQualityManagementPlan.WaterQualityManagementPlanBoundary; viewModel.UpdateModels(waterQualityManagementPlan); SetMessageForDisplay($"Successfully edited {FieldDefinitionType.Parcel.GetFieldDefinitionLabelPluralized()} for {FieldDefinitionType.WaterQualityManagementPlan.GetFieldDefinitionLabel()}."); var newBoundary = waterQualityManagementPlan.WaterQualityManagementPlanBoundary; if (!(oldBoundary == null && newBoundary == null)) { ModelingEngineUtilities.QueueLGURefreshForArea(oldBoundary, newBoundary); } NereidUtilities.MarkWqmpDirty(waterQualityManagementPlan, HttpRequestStorage.DatabaseEntities); return(RedirectToAction(new SitkaRoute <WaterQualityManagementPlanController>(c => c.Detail(waterQualityManagementPlan)))); }
public ActionResult EditModelingApproach(WaterQualityManagementPlanPrimaryKey waterQualityManagementPlanPrimaryKey, EditModelingApproachViewModel viewModel) { var waterQualityManagementPlan = waterQualityManagementPlanPrimaryKey.EntityObject; if (!ModelState.IsValid) { return(ViewEditModelingApproach(viewModel)); } viewModel.UpdateModel(waterQualityManagementPlan); if (waterQualityManagementPlan.WaterQualityManagementPlanBoundary != null) { ModelingEngineUtilities.QueueLGURefreshForArea(waterQualityManagementPlan.WaterQualityManagementPlanBoundary, null); NereidUtilities.MarkWqmpDirty(waterQualityManagementPlan, HttpRequestStorage.DatabaseEntities); } SetMessageForDisplay($"Modeling Approach successfully changed for {waterQualityManagementPlan.WaterQualityManagementPlanName}."); return(new ModalDialogFormJsonResult()); }
public ActionResult Delete(DelineationPrimaryKey delineationPrimaryKey, ConfirmDialogFormViewModel viewModel) { var delineation = delineationPrimaryKey.EntityObject; var geometry = delineation.DelineationGeometry; var isDelineationDistributed = delineation.DelineationType == DelineationType.Distributed; if (!ModelState.IsValid) { return(ViewDeleteDelineation(delineation, viewModel)); } delineation.DeleteDelineation(HttpRequestStorage.DatabaseEntities); SetMessageForDisplay("The Delineation was successfully deleted."); if (isDelineationDistributed) { ModelingEngineUtilities.QueueLGURefreshForArea(geometry, null); } return(new ModalDialogFormJsonResult( SitkaRoute <ManagerDashboardController> .BuildUrlFromExpression(c => c.Index()))); }
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 })); }