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 })); }
public ActionResult MarkBMPDelineationAsVerifiedModal(BulkRowTreatmentBMPViewModel viewModel) { if (!ModelState.IsValid) { return(new ModalDialogFormJsonResult()); } var bmpDelineations = HttpRequestStorage.DatabaseEntities.Delineations.Where(x => viewModel.EntityIDList.Contains(x.DelineationID)).ToList(); bmpDelineations.ForEach(x => x.MarkAsVerified(CurrentPerson)); NereidUtilities.MarkDelineationDirty(bmpDelineations, HttpRequestStorage.DatabaseEntities); var numberOfVerifiedBMPDelineations = bmpDelineations.Count; SetMessageForDisplay($"{numberOfVerifiedBMPDelineations} BMP Delineations were successfully verified."); return(new ModalDialogFormJsonResult()); }