diff --git a/zero.Core/Api/TranslationsApi.cs b/zero.Core/Api/TranslationsApi.cs index 5bf6137d..381acd76 100644 --- a/zero.Core/Api/TranslationsApi.cs +++ b/zero.Core/Api/TranslationsApi.cs @@ -2,6 +2,7 @@ using Raven.Client.Documents; using Raven.Client.Documents.Linq; using Raven.Client.Documents.Session; +using System; using System.Collections.Generic; using System.Threading.Tasks; using zero.Core.Entities; @@ -9,6 +10,28 @@ using zero.Core.Extensions; namespace zero.Core.Api { + public class TranslationsApiFacade : ITranslationsApiFacade + { + IServiceProvider Services; + + public TranslationsApiFacade(IServiceProvider services) + { + Services = services; + } + + public ITranslationsApi As() where T : ITranslation + { + return Services.GetService(typeof(ITranslationsApi)) as ITranslationsApi; + } + } + + + public interface ITranslationsApiFacade + { + ITranslationsApi As() where T : ITranslation; + } + + public class TranslationsApi : AppAwareBackofficeApi, ITranslationsApi where T : ITranslation { IValidator Validator; diff --git a/zero.Core/ServiceCollectionExtensions.cs b/zero.Core/ServiceCollectionExtensions.cs index 8677e33a..2e02bee3 100644 --- a/zero.Core/ServiceCollectionExtensions.cs +++ b/zero.Core/ServiceCollectionExtensions.cs @@ -24,6 +24,7 @@ namespace zero.Core.Entities services.AddTransient(); services.AddTransient(typeof(ITranslationsApi<>), typeof(TranslationsApi<>)); + services.AddTransient(typeof(ITranslationsApiFacade), typeof(TranslationsApiFacade)); } diff --git a/zero.Debug/Controllers/TestController.cs b/zero.Debug/Controllers/TestController.cs index 09f6faba..ca396b1a 100644 --- a/zero.Debug/Controllers/TestController.cs +++ b/zero.Debug/Controllers/TestController.cs @@ -45,6 +45,13 @@ namespace zero.Debug.Controllers } + [HttpGet] + public async Task GetTranslations([FromServices] ITranslationsApiFacade api) + { + return Json(await api.As().GetAll()); + } + + [HttpGet] public IActionResult Things([FromServices] IValidator appValidator) {