Exemplo n.º 1
0
 /// <summary>
 /// Calls the supplied <paramref name="action"/> expecting a <see cref="JsonResult"/>.
 /// If the action throws an exception the method will return <see cref="JsonResult"/>
 /// with an instance of <see cref="JsonErrorResult"/> for serialization
 /// back to javascript. Use this for consistent error handling in the client.
 /// </summary>
 /// <param name="action"></param>
 /// <returns></returns>
 protected JsonResult AttemptJsonAction(JsonActionDelegate action)
 {
     try
     {
         return(action());
     }
     catch (Exception ex)
     {
         return(JsonError(ex));
     }
 }
Exemplo n.º 2
0
 public JsonControllerAction(Method method, string path, JsonActionDelegate action) : base(method, path)
 {
     this.Action = action;
 }