private static async Task TranslateResponseAsync(HttpActionExecutedContext context, ITranslator translator, CancellationToken cancellationToken = default)
        {
            if (context.ActionContext?.Response?.Content == null)
            {
                return;
            }
            await context.ActionContext?.Response.Content.LoadIntoBufferAsync();

            var asString = await context.ActionContext?.Response?.Content?.ReadAsStringAsync();

            if (string.IsNullOrWhiteSpace(asString))
            {
                return;
            }

            var objectResult = JsonHelper.SafeDeserializeObject <JObject>(asString);

            if (objectResult == null)
            {
                return;
            }
            var itemBeforeTranslation = objectResult;

            await translator.Add(itemBeforeTranslation).ExecuteAsync(cancellationToken);

            var itemAfterTranslation = translator.Translate(itemBeforeTranslation, itemBeforeTranslation.GetType());

            context.ActionContext.Response.Content = new StringContent(JsonConvert.SerializeObject(itemAfterTranslation), Encoding.UTF8, "application/json");
        }
        private static async Task TranslateResponseAsync(ResultExecutingContext context, ITranslator translator,
                                                         CancellationToken cancellationToken)
        {
            if (context?.Result == null)
            {
                return;
            }
            if (!(context.Result is ObjectResult objectResult))
            {
                return;
            }
            if (objectResult.Value == null)
            {
                return;
            }

            var itemBeforeTranslation = objectResult.Value;

            await translator.Add(itemBeforeTranslation).ExecuteAsync(cancellationToken);

            var itemAfterTranslation = translator.Translate(itemBeforeTranslation, itemBeforeTranslation.GetType());

            context.Result = new ObjectResult(itemAfterTranslation);
        }