コード例 #1
0
        public ActionResult ChangeDelineationStatus(DelineationPrimaryKey delineationPrimaryKey,
                                                    ChangeDelineationStatusViewModel viewModel)
        {
            var delineation = delineationPrimaryKey.EntityObject;

            // todo: learn how to send a 400 or other error code with Json
            if (!ModelState.IsValid)
            {
                return(Json(new { success = false }));
            }

            delineation.IsVerified         = viewModel.IsVerified;
            delineation.DateLastVerified   = DateTime.Now;
            delineation.VerifiedByPersonID = CurrentPerson.PersonID;

            // if verifying delineation, execute model at the delineation
            // if de-verifying, execute model at its BMP
            if (delineation.IsVerified)
            {
                NereidUtilities.MarkDelineationDirty(delineation, HttpRequestStorage.DatabaseEntities);
            }
            else
            {
                NereidUtilities.MarkTreatmentBMPDirty(delineation.TreatmentBMP, HttpRequestStorage.DatabaseEntities);
            }

            return(Json(new { success = true }));
        }
コード例 #2
0
        /// <summary>
        /// The preference over delete-full for delineation. Nulls the DelineationID on any LGUs,
        /// deletes any overlaps, deletes the delineation itself, and marks the delineation's
        /// TreatmentBMP for a model run.
        /// </summary>
        /// <param name="treatmentBMPDelineation"></param>
        /// <param name="dbContext"></param>
        public static void DeleteDelineation(this Delineation treatmentBMPDelineation, DatabaseEntities dbContext)
        {
            var treatmentBMP = treatmentBMPDelineation.TreatmentBMP;

            foreach (var delineationLoadGeneratingUnit in treatmentBMPDelineation.LoadGeneratingUnits)
            {
                delineationLoadGeneratingUnit.DelineationID = null;
            }

            dbContext.SaveChanges();

            dbContext.DelineationOverlaps.DeleteDelineationOverlap(treatmentBMPDelineation
                                                                   .DelineationOverlaps);
            dbContext.DelineationOverlaps.DeleteDelineationOverlap(treatmentBMPDelineation
                                                                   .DelineationOverlapsWhereYouAreTheOverlappingDelineation);
            dbContext.Delineations.DeleteDelineation(treatmentBMPDelineation);
            dbContext.SaveChanges();

            NereidUtilities.MarkTreatmentBMPDirty(treatmentBMP, dbContext);
        }