Refactor, move data to respective project

This commit is contained in:
Wvader 2022-09-11 18:45:26 +01:00
parent 2c422b0685
commit 2a0d1f6a99
60 changed files with 189 additions and 144 deletions

View File

@ -43,7 +43,6 @@
<ItemGroup>
<ProjectReference Include="..\BlueWest.Data.Capital\BlueWest.Data.Capital.csproj" />
<ProjectReference Include="..\BlueWest.Data.Geography\BlueWest.Data.Geography.csproj" />
<ProjectReference Include="..\BlueWest\BlueWest.csproj" />
<ProjectReference Include="..\include\BlueWest.EfMethods\src\BlueWest.EfMethods\BlueWest.EfMethods.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />

View File

@ -1,15 +1,17 @@
using BlueWest.Data;
using BlueWest.EfMethods;
using BlueWest.WebApi.Context.Users;
using BlueWest.WebApi.EF.Model;
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
namespace BlueWest.WebApi.Context;
/// <summary>
/// Application User Db Context
/// </summary>
public class ApplicationUserDbContext : IdentityDbContext<
namespace BlueWest.WebApi.Context
{
/// <summary>
/// Application User Db Context
/// </summary>
[EfGenerator]
public class ApplicationUserDbContext : IdentityDbContext<
ApplicationUser,
ApplicationRole,
string,
@ -18,16 +20,20 @@ public class ApplicationUserDbContext : IdentityDbContext<
ApplicationUserLogin,
ApplicationRoleClaim,
ApplicationUserToken>
{
{
/// <inheritdoc />
[EfGetMany(typeof(ApplicationUserClaim))]
public sealed override DbSet<ApplicationUserClaim> UserClaims { get; set; }
[EfGetMany(typeof(ApplicationUserRole))]
/// <inheritdoc />
public sealed override DbSet<ApplicationUserRole> UserRoles { get; set; }
[EfGetMany(typeof(ApplicationRole))]
/// <inheritdoc />
public sealed override DbSet<ApplicationRole> Roles { get; set; }
[EfGetMany(typeof(ApplicationRoleClaim))]
/// <inheritdoc />
public sealed override DbSet<ApplicationRoleClaim> RoleClaims { get; set; }
@ -56,7 +62,6 @@ public class ApplicationUserDbContext : IdentityDbContext<
.HasKey(x => x.Id);
builder.Entity<ApplicationRole>(b =>
{
b.HasKey(r => r.Id);
@ -79,7 +84,7 @@ public class ApplicationUserDbContext : IdentityDbContext<
builder.Entity<ApplicationUserRole>(b =>
{
b.HasKey(r => new { r.UserId, r.RoleId });
b.HasKey(r => new {r.UserId, r.RoleId});
b.ToTable("UserRoles");
});
@ -93,5 +98,5 @@ public class ApplicationUserDbContext : IdentityDbContext<
builder.ConfigureCurrentDbModel();
}
}
}

View File

@ -1,6 +1,5 @@
using System;
using BlueWest.Data;
using BlueWest.WebApi.Context.Users;
using Microsoft.AspNetCore.Identity;

View File

@ -1,4 +1,3 @@
using BlueWest.Data;
using BlueWest.WebApi.Context.Users;
using Microsoft.AspNetCore.Identity;

View File

@ -20,7 +20,7 @@ namespace BlueWest.Cryptography
var fullText = string.Concat(text, salt);
var data = Encoding.UTF8.GetBytes(fullText);
string hash;
using SHA512 sha = new SHA512Managed();
using SHA512 sha = SHA512.Create();
var hashBytes = sha.ComputeHash(data);
var asString = ByteArrayToString(hashBytes);

View File

@ -2,7 +2,6 @@ using System;
using System.Text;
using System.Threading.Tasks;
using BlueWest.Cryptography;
using BlueWest.Data;
using BlueWest.WebApi.Context;
using BlueWest.WebApi.Context.Users;
using BlueWest.WebApi.EF;

View File

@ -3,7 +3,6 @@ using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using BlueWest.Cryptography;
using BlueWest.Data;
using Microsoft.AspNetCore.Identity;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;

View File

@ -1,7 +1,6 @@
using System.Threading;
using System.Threading.Tasks;
using BlueWest.Cryptography;
using BlueWest.Data;
using Microsoft.AspNetCore.Identity;
namespace BlueWest.WebApi.Context.Users;

View File

@ -1,5 +1,4 @@
using System.Threading.Tasks;
using BlueWest.Data;
using Microsoft.AspNetCore.Identity;
namespace BlueWest.WebApi.Context.Users;

View File

@ -1,8 +0,0 @@
namespace BlueWest.WebApi.Context.Users
{
internal class ClaimsDbExtensions
{
}
}

View File

@ -1,5 +1,4 @@
using System.Threading.Tasks;
using BlueWest.Data;
using Microsoft.AspNetCore.Identity;
namespace BlueWest.WebApi.Context.Users

View File

@ -1,17 +0,0 @@
using System;
using Microsoft.AspNetCore.Identity;
namespace BlueWest.WebApi.Context.Users;
/// <inheritdoc />
public class ApplicationRoleClaim : IdentityRoleClaim<string>
{
public sealed override int Id { get; set; }
public sealed override string RoleId { get; set; }
public sealed override string ClaimType { get; set; }
public sealed override string ClaimValue { get; set; }
}

View File

@ -1,14 +0,0 @@
using System;
using Microsoft.AspNetCore.Identity;
namespace BlueWest.WebApi.Context.Users;
/// <inheritdoc />
public class ApplicationUserRole : IdentityUserRole<string>
{
/// <inheritdoc />
public sealed override string UserId { get; set; }
/// <inheritdoc />
public sealed override string RoleId { get; set; }
}

View File

@ -2,7 +2,6 @@ using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using BlueWest.Data;
using BlueWest.WebApi.EF;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;

View File

@ -14,6 +14,13 @@ namespace BlueWest.WebApi.Context.Users
/// <inheritdoc />
public sealed override string NormalizedName { get; set; }
public ApplicationRole(ApplicationRole applicationRole)
{
Id = applicationRole.Id;
Name = applicationRole.Name;
NormalizedName = applicationRole.NormalizedName;
}
}
}

View File

@ -0,0 +1,33 @@
using System;
using Microsoft.AspNetCore.Identity;
namespace BlueWest.WebApi.Context.Users;
/// <inheritdoc />
public class ApplicationRoleClaim : IdentityRoleClaim<string>
{
public sealed override int Id { get; set; }
#region ApplicationRole
public sealed override string RoleId { get; set; }
public ApplicationRole ApplicationRole { get; set; }
#endregion
public sealed override string ClaimType { get; set; }
public sealed override string ClaimValue { get; set; }
public ApplicationRoleClaim() { }
public ApplicationRoleClaim(ApplicationRoleClaim applicationRoleClaim)
{
Id = applicationRoleClaim.Id;
RoleId = applicationRoleClaim.RoleId;
ApplicationRole = applicationRoleClaim.ApplicationRole;
ClaimType = applicationRoleClaim.ClaimType;
ClaimValue = applicationRoleClaim.ClaimValue;
}
}

View File

@ -8,9 +8,17 @@ public class ApplicationUserClaim : IdentityUserClaim<string>
/// <inheritdoc />
public sealed override int Id { get; set; }
#region User
/// <inheritdoc />
public sealed override string UserId { get; set; }
/// <summary>
/// Application User entity
/// </summary>
public ApplicationUser ApplicationUser { get; set; }
#endregion
/// <inheritdoc />
public sealed override string ClaimType { get; set; }
@ -21,6 +29,7 @@ public class ApplicationUserClaim : IdentityUserClaim<string>
{
Id = applicationUserClaim.Id;
UserId = applicationUserClaim.UserId;
ApplicationUser = applicationUserClaim.ApplicationUser;
ClaimType = applicationUserClaim.ClaimType;
ClaimValue = applicationUserClaim.ClaimValue;
}

View File

@ -0,0 +1,33 @@
using System;
using System.Collections.Generic;
using Microsoft.AspNetCore.Identity;
namespace BlueWest.WebApi.Context.Users;
/// <inheritdoc />
public class ApplicationUserRole : IdentityUserRole<string>
{
/// <summary>
/// User entity of this role
/// </summary>
public ApplicationUser User { get; set; }
public ApplicationRole ApplicationRole { get; set; }
/// <inheritdoc />
public sealed override string UserId { get; set; }
/// <inheritdoc />
public sealed override string RoleId { get; set; }
public ApplicationUserRole() { }
public ApplicationUserRole(ApplicationUserRole applicationUserRole)
{
User = applicationUserRole.User;
UserId = applicationUserRole.UserId;
RoleId = applicationUserRole.RoleId;
ApplicationRole = applicationUserRole.ApplicationRole;
}
}

View File

@ -15,6 +15,16 @@
<ItemGroup>
<Content Include="obj\rider.project.restore.info" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Identity.Core" Version="6.0.7" />
<PackageReference Include="Microsoft.Extensions.Identity.Stores" Version="6.0.7" />
</ItemGroup>
<ItemGroup>
<Folder Include="Application" />
<Folder Include="Capital" />
</ItemGroup>
<Import Project="..\include\BlueWest.MapTo\src\BlueWest.MapTo\MapTo.props" />
</Project>

View File

@ -1,3 +1,5 @@
using System;
namespace BlueWest.Data.Geography
{
public partial class Coordinate

@ -1 +1 @@
Subproject commit 34cd3cc52a676cf2d9cacfb3c83a3413ac94b726
Subproject commit 2afc7cc1eb60369db3d2db021d514647baba93dc

View File

@ -34,8 +34,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Core", "Core", "{552B9217-4
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BlueWest.Api.Gateway", "BlueWest.Api.Gateway\BlueWest.Api.Gateway.csproj", "{A78343AF-77C6-48FD-A9C4-F8B7CBA56212}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BlueWest.Data.Geography", "BlueWest.Data.Geography\BlueWest.Data.Geography.csproj", "{D5924A3F-0AA1-4AF4-AEDB-3B9F91E6531E}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BlueWest.EfMethods", "include\BlueWest.EfMethods\src\BlueWest.EfMethods\BlueWest.EfMethods.csproj", "{BBF5E860-A880-450B-B6C9-EF92F6421B3D}"
EndProject
Global
@ -76,10 +74,6 @@ Global
{A78343AF-77C6-48FD-A9C4-F8B7CBA56212}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A78343AF-77C6-48FD-A9C4-F8B7CBA56212}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A78343AF-77C6-48FD-A9C4-F8B7CBA56212}.Release|Any CPU.Build.0 = Release|Any CPU
{D5924A3F-0AA1-4AF4-AEDB-3B9F91E6531E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D5924A3F-0AA1-4AF4-AEDB-3B9F91E6531E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D5924A3F-0AA1-4AF4-AEDB-3B9F91E6531E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D5924A3F-0AA1-4AF4-AEDB-3B9F91E6531E}.Release|Any CPU.Build.0 = Release|Any CPU
{BBF5E860-A880-450B-B6C9-EF92F6421B3D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BBF5E860-A880-450B-B6C9-EF92F6421B3D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BBF5E860-A880-450B-B6C9-EF92F6421B3D}.Release|Any CPU.ActiveCfg = Release|Any CPU