This commit is contained in:
CodeLiturgy 2022-09-10 05:28:41 +01:00
parent 5c32055f6a
commit 015a7396ad
13 changed files with 48 additions and 13 deletions

View File

@ -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>

View File

@ -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" />

View File

@ -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;

View File

@ -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;
}

View File

@ -51,7 +51,7 @@ namespace BlueWest.WebApi.Controllers
int orderDir = 1)
{
var (success, countries) = _dbContext.GetCountries(skip, take, orderDir);
var (success, countries) = _dbContext.GetCountries( skip, take, orderDir);
if (!success) return new NotFoundResult();
return Ok(countries);

View File

@ -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();

View File

@ -99,22 +99,20 @@ 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>();
services
.AddScoped<UserRepository>()
.AddScoped< UserRepository>()
.AddScoped<IUserManager, UserManager>()
.AddScoped<IAuthManager, AuthManager>()
.AddScoped<IHasher, Hasher>();

View File

@ -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>

View File

@ -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();
}

View File

@ -11,6 +11,6 @@
"DockerMySQL": "server=db;user=blueuser;password=dXjw127124dJ;database=bluedb;"
},
"AuthSettings": {
"SecretKey": "d123d123d123fff12"
"SecretKey": "iJWHDmHLpUA283sqsfhqGbMRdRj1PVkH"
}
}

View File

@ -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>

View File

@ -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>

View File

@ -7,4 +7,8 @@
<RootNamespace>PerformanceSolution</RootNamespace>
</PropertyGroup>
<ItemGroup>
<Content Include="obj\rider.project.restore.info" />
</ItemGroup>
</Project>