public async Task OnResultExecutionAsync(ResultExecutingContext context, ResultExecutionDelegate next) { if (_notificationContext.HasNotifications) { context.HttpContext.Response.StatusCode = (int)HttpStatusCode.BadRequest; context.HttpContext.Response.ContentType = "application/json"; var notifications = JsonConvert.SerializeObject(_notificationContext.GetNotifications()); await context.HttpContext.Response.WriteAsync(notifications); return; } await next(); }
protected new IActionResult Response(object result = null) { if (IsValidOperation()) { return(Ok(new { success = true, data = result })); } return(BadRequest(new { success = false, errors = _notifications.GetNotifications().Select(n => n.Message) })); }