public ActionResult CreateImperative(PersonModel model) { var result = ImperativePersonContext.Add(model.ToPerson()); if (result.Successful) { return RedirectToAction("Index"); } model.Messages.AddRange(result.Messages); return View(model); }
public ActionResult Create(PersonModel model) { var result = PersonContext.Add(model.ToPerson()); // Pattern Matching!!! return result.Either( (msgs, p) => RedirectToAction("Index"), (msgs) => { model.Messages = msgs.ToList(); return (ActionResult)View(model); } ); }