diff options
Diffstat (limited to 'code/api/src/Endpoints/EndpointBase.cs')
| -rw-r--r-- | code/api/src/Endpoints/EndpointBase.cs | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/code/api/src/Endpoints/EndpointBase.cs b/code/api/src/Endpoints/EndpointBase.cs new file mode 100644 index 0000000..c088976 --- /dev/null +++ b/code/api/src/Endpoints/EndpointBase.cs @@ -0,0 +1,27 @@ +using System.Diagnostics; + +namespace IOL.GreatOffice.Api.Endpoints; + +[ApiController] +public class EndpointBase : ControllerBase +{ + /// <summary> + /// User data for the currently logged on user. + /// </summary> + protected LoggedInUserModel LoggedInUser => new() { + Username = User.FindFirstValue(AppClaims.NAME), + Id = User.FindFirstValue(AppClaims.USER_ID).AsGuid(), + }; + + public ObjectResult KnownProblem(string title = default, string subtitle = default, Dictionary<string, string> errors = default) { + return new ObjectResult(new KnownProblemModel { + Title = title, + Subtitle = subtitle, + Errors = errors, + TraceId = Activity.Current?.Id, + RequestId = HttpContext.TraceIdentifier + }) { + StatusCode = (int) HttpStatusCode.BadRequest + }; + } +}
\ No newline at end of file |
