/// <summary>
 /// On Action Executing
 /// </summary>
 /// <param name="context">Action Executing Context</param>
 public override void OnActionExecuting(ActionExecutingContext context)
 {
     if (!context.ModelState.IsValid)
     {
         context.Result = new BadRequestObjectResult(CustomReturn.ModelStateReturn(context.HttpContext.Request, context.ModelState));
     }
 }
예제 #2
0
        /// <summary>
        /// On Exception Pipeline
        /// </summary>
        /// <param name="context">Exception Context</param>
        public void OnException(ExceptionContext context)
        {
            var customReturn = CustomReturn.ExceptionReturn(context.HttpContext.Request, context.Exception);

            context.HttpContext.Response.StatusCode  = customReturn.Status.Value;
            context.HttpContext.Response.ContentType = "application/json";
            context.Result = new BadRequestObjectResult(customReturn);

            _logger.LogError(context.Exception, customReturn.Detail);
        }
예제 #3
0
 /// <summary>
 /// On Notification Result
 /// </summary>
 /// <param name="context">Exception Context</param>
 /// <param name="next">Next Execution</param>
 public async Task OnResultExecutionAsync(ResultExecutingContext context, ResultExecutionDelegate next)
 {
     if (!notificationContext.HasReturn)
     {
         await next();
     }
     else
     {
         await CustomReturn.PutResponse(context.HttpContext.Response,
                                        CustomReturn.NotificationReturn(context.HttpContext.Request, notificationContext));
     }
 }
예제 #4
0
 public IActionResult Error()
 {
     return(View(CustomReturn.NotificationReturn(Request, _notification)));
 }