From 67c858ec5689815a45b46efa5e3c70aa1c336b85 Mon Sep 17 00:00:00 2001 From: Claudia Murialdo Date: Wed, 8 Jan 2025 12:17:38 +0000 Subject: [PATCH] Cherry pick branch 'genexuslabs:rest-service-as-controller' into beta --- .../GxClasses.Web/Middleware/GXRestServices.cs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/dotnet/src/dotnetcore/GxClasses.Web/Middleware/GXRestServices.cs b/dotnet/src/dotnetcore/GxClasses.Web/Middleware/GXRestServices.cs index f0bcdde20..e41343e7e 100644 --- a/dotnet/src/dotnetcore/GxClasses.Web/Middleware/GXRestServices.cs +++ b/dotnet/src/dotnetcore/GxClasses.Web/Middleware/GXRestServices.cs @@ -130,7 +130,7 @@ protected ActionResult UploadImpl() SetStatusCode(HttpStatusCode.Created); return GetResponse(new {object_id = fileToken}); } - protected ActionResult ErrorCheck(IGxSilentTrn trn) + protected void ErrorCheck(IGxSilentTrn trn) { if (trn.Errors() == 1) { @@ -146,12 +146,20 @@ protected ActionResult ErrorCheck(IGxSilentTrn trn) _errorDetail = HandleError(HttpStatusCode.BadRequest.ToString(HttpHelper.INT_FORMAT), msgItem.gxTpr_Description); } } + } + protected ActionResult GetErrorResponse(IGxSilentTrn trn) + { + ErrorCheck(trn); if (_errorDetail == null) return NoContent(); else return GetResponse(_errorDetail); - } + protected ActionResult GetErrorResponse(string code, string message) + { + return GetResponse(HandleError(code, message)); + } + protected void SetMessages(msglist messages) { StringBuilder header = new StringBuilder(); @@ -344,7 +352,6 @@ internal WrappedJsonError HandleError(string code, string message) SetErrorHeaders(HttpContext, httpStatusCode, message); return HttpHelper.GetJsonError(code, message); } - private void SetErrorHeaders(HttpContext httpContext, HttpStatusCode httpStatusCode, string message) { if (httpContext != null)