private PartialViewResult ViewDeleteDelineation(Delineation delineation, ConfirmDialogFormViewModel viewModel)
        {
            var confirmMessage =
                $"Are you sure you want to delete the delineation for '{delineation.TreatmentBMP.TreatmentBMPName}'?";

            var viewData = new ConfirmDialogFormViewData(confirmMessage, true);

            return(RazorPartialView <ConfirmDialogForm, ConfirmDialogFormViewData, ConfirmDialogFormViewModel>(viewData,
                                                                                                               viewModel));
        }
        private PartialViewResult ViewDelete(Delineation delineation, ConfirmDialogFormViewModel viewModel)
        {
            var canDelete      = delineation.CanDelete(CurrentPerson);
            var confirmMessage = canDelete
                ? "Are you sure you want to delete the Delineation?"
                : ConfirmDialogFormViewData.GetStandardCannotDeleteMessage("Delineation", SitkaRoute <TreatmentBMPController> .BuildLinkFromExpression(x => x.Index(), "here"));

            var viewData = new ConfirmDialogFormViewData(confirmMessage, canDelete);

            return(RazorPartialView <ConfirmDialogForm, ConfirmDialogFormViewData, ConfirmDialogFormViewModel>(viewData, viewModel));
        }
示例#3
0
        public static void MarkDelineationDirty(Delineation delineation, DatabaseEntities dbContext)
        {
            var dirtyModelNode = new DirtyModelNode(DateTime.Now)
            {
                DelineationID = delineation.DelineationID
            };

            dbContext.DirtyModelNodes.Add(dirtyModelNode);

            dbContext.SaveChanges();
        }
        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 }));
        }
示例#5
0
 public static string DelineationNodeID(Delineation delineation)
 {
     return("Delineation_" + delineation.DelineationID);
 }