예제 #1
0
        private async Task WriteExceptionAsync(HttpContext context, Exception exception)
        {
            var response = context.Response;

            response.StatusCode  = (int)HttpStatusCode.OK;
            response.ContentType = "application/json";
            await response.WriteAsync(JsonConvert.SerializeObject(DkmsResult.Failure(message: exception.Message))).ConfigureAwait(false);
        }
예제 #2
0
 public override void OnResultExecuting(ResultExecutingContext context)
 {
     if (context.Result is ObjectResult)
     {
         var objectResult = context.Result as ObjectResult;
         if (objectResult.Value == null)
         {
             SetResponse(context, DkmsResult.Success(string.Empty));
         }
         else
         {
             SetResponse(context, DkmsResult.Success(objectResult.Value));
         }
     }
     else if (context.Result is EmptyResult)
     {
         SetResponse(context, DkmsResult.Success(string.Empty));
     }
     else if (context.Result is ContentResult)
     {
         SetResponse(context, DkmsResult.Success((context.Result as ContentResult).Content));
     }
 }
예제 #3
0
 private void SetResponse(ResultExecutingContext context, DkmsResult result)
 {
     context.Result = new ObjectResult(result);
 }