ActionResult ProcessDialog(DialogModel model, int answer, string message) { if (ModelState.IsValid) { if (model.Value == answer) return this.DialogResult(message); // Close dialog via DialogResult call else ModelState.AddModelError("", string.Format("Invalid input value. The correct value is {0}", answer)); } return PartialView(model); }
ActionResult ProcessDialog(DialogModel model, int answer, string message) { if (this.ModelState.IsValid) { var data = new { id = answer, valor = "Mensagem " + answer }; if (model.Value == answer) { return this.DialogResult(message, data); // Close dialog via DialogResult call } this.ModelState.AddModelError(string.Empty, string.Format("Invalid input value. The correct value is {0}", answer)); } return this.PartialView(model); }
ActionResult ProcessDialog(DialogModel model, int answer) { return ProcessDialog(model, answer, null); }
public ActionResult Dialog3(DialogModel model) { return ProcessDialog(model, 3); }
public ActionResult Dialog1(DialogModel model) { return ProcessDialog(model, 1, "Great, your answer is correct!"); }
public ActionResult Dialog2(DialogModel model) { return this.ProcessDialog(model, 2); }