コード例 #1
0
 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);
 }
コード例 #2
0
 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);
                     }
                     );
 }