private bool RedactionIsValid(FeatureRedactionRecord redaction) { var currentRedaction = GetRedactions().FirstOrDefault(r => r.FeatureId == redaction.FeatureId); if (currentRedaction == null) { return true; } return currentRedaction.Id == redaction.Id; }
public RedactionOperationStatus UpdateRedaction(FeatureRedactionRecord redaction) { if (!RedactionIsValid(redaction)) { return RedactionOperationStatus.NotUnique; } _repository.Update(redaction); return RedactionOperationStatus.Updated; }
public RedactionOperationStatus DeleteRedaction(FeatureRedactionRecord redaction) { _repository.Delete(redaction); return RedactionOperationStatus.Removed; }
public ActionResult EditFeatureRedactionDelete(FeatureRedactionRecord redaction, int id = 0) { redaction.Id = id; _featureRedactionService.DeleteRedaction(redaction); _notifier.Information(T("Feature Redaction deleted")); return RedirectToAction("Index"); }
public ActionResult EditFeatureRedactionPost(FeatureRedactionRecord redaction, int id = 0) { redaction.Id = id; var status = _featureRedactionService.UpdateRedaction(redaction); switch (status) { case RedactionOperationStatus.Created: _notifier.Information(T("Feature Redaction created")); break; case RedactionOperationStatus.Updated: _notifier.Information(T("Feature Redaction updated")); break; case RedactionOperationStatus.NotUnique: _notifier.Error(T("Feature Redaction could not be saved because there is already a feature redaction for the feature {0}.", redaction.FeatureId)); return View(redaction); } return RedirectToAction("Index"); }