try rewirte of all backoffice controllers to ApiControllers
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Http.Extensions;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Raven.Client.Documents;
|
||||
using Raven.Client.Documents.Session;
|
||||
using System;
|
||||
@@ -29,15 +30,18 @@ namespace zero.Core.Api
|
||||
|
||||
protected UserManager<User> UserManager { get; private set; }
|
||||
|
||||
protected ILogger<ApplicationContext> Logger { get; private set; }
|
||||
|
||||
static IList<IApplication> Apps { get; set; }
|
||||
|
||||
|
||||
|
||||
public ApplicationContext(IDocumentStore raven, IZeroOptions options, UserManager<User> userManager)
|
||||
public ApplicationContext(IDocumentStore raven, IZeroOptions options, UserManager<User> userManager, ILogger<ApplicationContext> logger)
|
||||
{
|
||||
Raven = raven;
|
||||
Options = options;
|
||||
UserManager = userManager;
|
||||
Logger = logger;
|
||||
}
|
||||
|
||||
|
||||
@@ -62,7 +66,9 @@ namespace zero.Core.Api
|
||||
|
||||
if (app == null)
|
||||
{
|
||||
throw new NullReferenceException($"Could not resolve application for host {context.Request.Host}");
|
||||
Logger.LogWarning($"Could not resolve application for host $host", context.Request.Host);
|
||||
IList<IApplication> apps = await GetApplications();
|
||||
app = apps.FirstOrDefault();
|
||||
}
|
||||
|
||||
App = app;
|
||||
@@ -171,7 +177,7 @@ namespace zero.Core.Api
|
||||
using IAsyncDocumentSession session = Raven.OpenAsyncSession();
|
||||
IApplication app = await session.LoadAsync<Application>(appId);
|
||||
|
||||
return new ApplicationContext(Raven, Options, UserManager)
|
||||
return new ApplicationContext(Raven, Options, UserManager, Logger)
|
||||
{
|
||||
App = app,
|
||||
AppId = appId
|
||||
|
||||
@@ -7,19 +7,17 @@ namespace zero.Core.Options
|
||||
{
|
||||
public class BackofficeJsonSerlializerSettings : JsonSerializerSettings
|
||||
{
|
||||
public BackofficeJsonSerlializerSettings() : this(false) { }
|
||||
|
||||
public BackofficeJsonSerlializerSettings(bool typed)
|
||||
public BackofficeJsonSerlializerSettings()
|
||||
{
|
||||
Setup(this, typed);
|
||||
Setup(this);
|
||||
}
|
||||
|
||||
|
||||
public static void Setup(JsonSerializerSettings settings, bool typed = false)
|
||||
public static void Setup(JsonSerializerSettings settings)
|
||||
{
|
||||
settings.Converters.Add(new StringEnumConverter(new CamelCaseNamingStrategy()));
|
||||
settings.Converters.Add(new RefJsonConverter());
|
||||
settings.ContractResolver = new ZeroJsonContractResolver();
|
||||
//settings.Converters.Add(new RefJsonConverter());
|
||||
//settings.ContractResolver = new ZeroJsonContractResolver();
|
||||
settings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
|
||||
settings.TypeNameHandling = TypeNameHandling.Objects;
|
||||
//settings.SerializationBinder = new ZeroInterfaceBinder();
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace zero.Core.Routing
|
||||
AffectedTypes = new Type[1] { typeof(T) };
|
||||
DefaultEndpoint = new RouteProviderEndpoint()
|
||||
{
|
||||
Controller = "DefaultRoute",
|
||||
Controller = "ZeroFrontend",
|
||||
Action = "Index"
|
||||
};
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
{
|
||||
DefaultEndpoint = new RouteProviderEndpoint()
|
||||
{
|
||||
Controller = "DefaultRoute",
|
||||
Controller = "ZeroFrontend",
|
||||
Action = "Index"
|
||||
};
|
||||
}
|
||||
|
||||
@@ -20,8 +20,8 @@
|
||||
<PackageReference Include="FluentValidation" Version="9.1.2" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Identity" Version="2.2.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.Core" Version="2.2.5" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="5.0.0-preview.8.20407.11" />
|
||||
<PackageReference Include="RavenDB.Client" Version="5.0.2" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="5.0.0-rc.2.20475.5" />
|
||||
<PackageReference Include="RavenDB.Client" Version="5.0.3" />
|
||||
<PackageReference Include="SixLabors.ImageSharp" Version="1.0.1" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user