This commit is contained in:
parent
5c32055f6a
commit
015a7396ad
|
@ -12,4 +12,10 @@
|
|||
<ProjectReference Include="..\BlueWest\BlueWest.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Content Include="obj\Debug\net6.0\apphost.exe" />
|
||||
<Content Include="obj\Debug\net6.0\BlueWest.Api.Gateway.csproj.FileListAbsolute.txt" />
|
||||
<Content Include="obj\rider.project.restore.info" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
@ -49,6 +49,10 @@
|
|||
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Content Include="obj\rider.project.restore.info" />
|
||||
</ItemGroup>
|
||||
|
||||
<Import Project="..\include\BlueWest.EfMethods\src\BlueWest.EfMethods\BlueWest.EfMethods.props" />
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using BlueWest.Tools;
|
||||
using BlueWest.WebApi.Context.Users;
|
||||
using BlueWest.WebApi.EF;
|
||||
|
||||
namespace BlueWest.WebApi.Interfaces
|
||||
|
@ -16,6 +17,7 @@ namespace BlueWest.WebApi.Interfaces
|
|||
///
|
||||
public sealed class ExchangeInterface : EventListener<ExchangeEvent>, IDisposable, IAsyncDisposable
|
||||
{
|
||||
private readonly ApplicationUserDbContext _applicationUserDbContext;
|
||||
private readonly EventManager _eventManager;
|
||||
private readonly CountryDbContext _countryDbContext;
|
||||
private readonly FinanceDbContext _financeDbContext;
|
||||
|
@ -32,11 +34,13 @@ namespace BlueWest.WebApi.Interfaces
|
|||
/// <param name="eventManager">Event manager injection</param>
|
||||
|
||||
public ExchangeInterface(
|
||||
ApplicationUserDbContext applicationUserDbContext,
|
||||
CountryDbContext countryDbContext,
|
||||
FinanceDbContext financeDbContext,
|
||||
UserDbContext userDbContext,
|
||||
EventManager eventManager)
|
||||
{
|
||||
_applicationUserDbContext = applicationUserDbContext;
|
||||
_countryDbContext = countryDbContext;
|
||||
_financeDbContext = financeDbContext;
|
||||
_userDbContext = userDbContext;
|
||||
|
|
|
@ -25,6 +25,7 @@ namespace BlueWest.WebApi.EF.Model
|
|||
.ConfigureDatabaseKeys()
|
||||
.CurrencyModel()
|
||||
.ConfigureUserModel();
|
||||
|
||||
//.ConfigureIdentityModel();
|
||||
}
|
||||
|
||||
|
@ -110,8 +111,6 @@ namespace BlueWest.WebApi.EF.Model
|
|||
|
||||
private static ModelBuilder ConfigureUserModel(this ModelBuilder modelBuilder)
|
||||
{
|
||||
|
||||
|
||||
// FinanceOp => User
|
||||
modelBuilder
|
||||
.Entity<FinanceOp>(builder => builder
|
||||
|
@ -119,6 +118,9 @@ namespace BlueWest.WebApi.EF.Model
|
|||
.WithMany(ft => ft.FinanceTransactions)
|
||||
.HasForeignKey(x => x.UserId));
|
||||
|
||||
modelBuilder.Entity<User>(b => b.HasOne<ApplicationUser>()
|
||||
.WithMany(x => x.Users)
|
||||
.HasForeignKey(x => x.ApplicationUserId));
|
||||
|
||||
return modelBuilder;
|
||||
}
|
||||
|
|
|
@ -132,7 +132,7 @@ namespace BlueWest.WebApi
|
|||
throw new InvalidOperationException("config.json doesn't specify a valid database. Use mysql or sqlite.");
|
||||
}
|
||||
|
||||
services.AddAuthServerServices(MyAllowSpecificOrigins, _configuration, _environment);
|
||||
services = services.AddAuthServerServices(MyAllowSpecificOrigins, _configuration, _environment);
|
||||
|
||||
|
||||
services.AddScoped<ExchangeInterface>();
|
||||
|
@ -160,7 +160,7 @@ namespace BlueWest.WebApi
|
|||
c.RoutePrefix = "swagger";
|
||||
c.SwaggerEndpoint("/swagger/v1/swagger.json", "BlueWest.Api v1");
|
||||
});
|
||||
//app.UseStaticFiles();
|
||||
app.UseStaticFiles();
|
||||
//app.UseHttpsRedirection();
|
||||
|
||||
|
||||
|
|
|
@ -99,15 +99,13 @@ namespace BlueWest.WebApi
|
|||
.AddDbContextPool<UserDbContext>(options => options.UseSqlite(sqliteConString))
|
||||
.AddDbContextPool<CountryDbContext>(options => options.UseSqlite(sqliteConString))
|
||||
.AddDbContextPool<FinanceDbContext>(options => options.UseSqlite(sqliteConString))
|
||||
.AddDbContextPool<CompanyDbContext>(options => options.UseSqlite(sqliteConString));
|
||||
.AddDbContextPool<CompanyDbContext>(options => options.UseSqlite(sqliteConString))
|
||||
.AddDbContextPool<ApplicationUserDbContext>(options => options.UseSqlite(sqliteConString));
|
||||
|
||||
}
|
||||
|
||||
public static IServiceCollection AddAuthServerServices(this IServiceCollection services, string origins, IConfiguration configuration , IWebHostEnvironment environment)
|
||||
{
|
||||
var sqliteConString = "Data Source=BlueWest.Api.db";
|
||||
|
||||
services.AddDbContext<ApplicationUserDbContext>(options => options.UseSqlite(sqliteConString));
|
||||
|
||||
services.AddScoped<IJwtTokenHandler, JwtTokenHandler>();
|
||||
services.AddScoped<IJwtFactory, JwtFactory>();
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using BlueWest.Data;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
|
||||
namespace BlueWest.WebApi.Context.Users;
|
||||
|
@ -18,6 +20,7 @@ public class ApplicationUser : IdentityUser<string>
|
|||
[PersonalData]
|
||||
public new string Id { get; set; }
|
||||
|
||||
public List<User> Users { get; set; }
|
||||
/// <summary>
|
||||
/// Gets or sets the user name for this user.
|
||||
/// </summary>
|
||||
|
|
|
@ -52,6 +52,8 @@ public class ApplicationUserDbContext : IdentityDbContext<
|
|||
{
|
||||
base.OnModelCreating(builder);
|
||||
|
||||
|
||||
builder.Entity<ApplicationUserRole>().ToTable("UserRoles");
|
||||
builder.Entity<ApplicationUser>(b =>
|
||||
{
|
||||
b.HasMany<ApplicationUserRole>()
|
||||
|
@ -90,6 +92,10 @@ public class ApplicationUserDbContext : IdentityDbContext<
|
|||
b.ToTable("UserRoles");
|
||||
});
|
||||
|
||||
builder.Entity<User>(b => b.HasOne<ApplicationUser>()
|
||||
.WithMany(x => x.Users)
|
||||
.HasForeignKey(x => x.ApplicationUserId));
|
||||
|
||||
builder.ConfigureCurrentDbModel();
|
||||
}
|
||||
|
||||
|
|
|
@ -11,6 +11,6 @@
|
|||
"DockerMySQL": "server=db;user=blueuser;password=dXjw127124dJ;database=bluedb;"
|
||||
},
|
||||
"AuthSettings": {
|
||||
"SecretKey": "d123d123d123fff12"
|
||||
"SecretKey": "iJWHDmHLpUA283sqsfhqGbMRdRj1PVkH"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,6 +11,10 @@
|
|||
<ProjectReference Include="..\include\BlueWest.MapTo\src\BlueWest.MapTo\BlueWest.MapTo.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />
|
||||
<ProjectReference Include="..\include\Math-Expression-Evaluator\SimpleExpressionEvaluator\SimpleExpressionEvaluator.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Content Include="obj\rider.project.restore.info" />
|
||||
</ItemGroup>
|
||||
<Import Project="..\include\BlueWest.MapTo\src\BlueWest.MapTo\MapTo.props" />
|
||||
|
||||
</Project>
|
||||
|
|
|
@ -11,4 +11,8 @@
|
|||
<ProjectReference Include="..\include\BlueWest.MapTo\src\BlueWest.MapTo\BlueWest.MapTo.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Content Include="obj\rider.project.restore.info" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
@ -7,4 +7,8 @@
|
|||
<RootNamespace>PerformanceSolution</RootNamespace>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Content Include="obj\rider.project.restore.info" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
Loading…
Reference in New Issue