AppUser new structure

master
Tudor Stanciu 2021-11-11 01:20:02 +02:00
parent 4f0db24b5b
commit 4f30ab0c98
7 changed files with 50 additions and 4 deletions

View File

@ -1,7 +1,7 @@
{
"urls": "http://*:5063",
"ConnectionStrings": {
"DatabaseConnection": "Server=***REMOVED***;Database=IdentityServer_dev;User Id=sa;Password=***REMOVED***;MultipleActiveResultSets=true"
"DatabaseConnection": "***REMOVED***"
},
"Logging": {
"LogLevel": {

View File

@ -10,6 +10,7 @@ namespace IdentityServer.Domain.Data.EntityTypeConfiguration
{
builder.ToTable("AppUser").HasKey(key => key.UserId);
builder.Property(z => z.UserId).ValueGeneratedOnAdd();
builder.HasOne(z => z.Status).WithMany().HasForeignKey(z => z.StatusId);
}
}
}

View File

@ -0,0 +1,15 @@
using IdentityServer.Domain.Entities;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace IdentityServer.Domain.Data.EntityTypeConfiguration
{
class UserStatusConfiguration : IEntityTypeConfiguration<UserStatus>
{
public void Configure(EntityTypeBuilder<UserStatus> builder)
{
builder.ToTable("UserStatus").HasKey(z => z.StatusId);
builder.Property(z => z.StatusId).ValueGeneratedOnAdd();
}
}
}

View File

@ -2,7 +2,7 @@ if not exists (select top 1 1 from sys.objects where name = 'UserStatus' and typ
begin
create table UserStatus
(
StatusId int identity(0, 1) constraint PK_UserStatus primary key,
StatusId int identity(1, 1) constraint PK_UserStatus primary key,
StatusCode varchar(30) not null,
StatusName varchar(50) not null
)

View File

@ -1,3 +1,10 @@
if exists (select top 1 1 from sys.objects where name = 'AppUser' and type = 'U')
and not exists(select top 1 1 from sys.columns where name = 'SecurityStamp' and object_id = object_id('AppUser'))
begin
select * into #TmpAppUser from AppUser
drop table AppUser
end
if not exists (select top 1 1 from sys.objects where name = 'AppUser' and type = 'U')
begin
create table AppUser
@ -21,7 +28,13 @@ go
if not exists (select top 1 1 from AppUser)
begin
insert into AppUser(UserName, [Password])
select '***REMOVED***', '***REMOVED***'
declare @activeStatusId int
select @activeStatusId = StatusId from UserStatus where StatusCode = 'ACTIVE'
insert into AppUser(UserName, [Password], CreationDate, SecurityStamp, StatusId)
select UserName, [Password], CreationDate, cast(newid() as varchar(100)), @activeStatusId as StatusId
from #TmpAppUser
drop table #TmpAppUser
end
go

View File

@ -7,8 +7,16 @@ namespace IdentityServer.Domain.Entities
public int UserId { get; set; }
public string UserName { get; set; }
public string Password { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public string Email { get; set; }
public string ProfilePictureUrl { get; set; }
public string SecurityStamp { get; set; }
public int StatusId { get; set; }
public DateTime CreationDate { get; set; }
public int FailedLoginAttempts { get; set; }
public DateTime LastLoginDate { get; set; }
public DateTime PasswordChangeDate { get; set; }
public UserStatus Status { get; set; }
}
}

View File

@ -0,0 +1,9 @@
namespace IdentityServer.Domain.Entities
{
public class UserStatus
{
public int StatusId { get; set; }
public string StatusCode { get; set; }
public string StatusName { get; set; }
}
}