DbContext y clases de configuracion y usuario creados
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
using CleanArchitecture.Identity.Configurations;
|
||||
using CleanArchitecture.Identity.Models;
|
||||
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace CleanArchitecture.Identity
|
||||
{
|
||||
public class CleanArchitectureIdentityDbContext : IdentityDbContext<ApplicationUser>
|
||||
{
|
||||
public CleanArchitectureIdentityDbContext(DbContextOptions<CleanArchitectureIdentityDbContext> options) : base(options)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder builder)
|
||||
{
|
||||
base.OnModelCreating(builder);
|
||||
|
||||
builder.ApplyConfiguration(new RoleConfiguration());
|
||||
builder.ApplyConfiguration(new UserConfiguration());
|
||||
builder.ApplyConfiguration(new UserRoleConfiguration());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace CleanArchitecture.Identity.Configurations
|
||||
{
|
||||
public class RoleConfiguration : IEntityTypeConfiguration<IdentityRole>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<IdentityRole> builder)
|
||||
{
|
||||
builder.HasData(
|
||||
new IdentityRole
|
||||
{
|
||||
Id = "26f31fc8-f911-4761-956f-e72c0041c9c9",
|
||||
Name = "Administrator",
|
||||
NormalizedName = "ADMINISTRATOR"
|
||||
},
|
||||
new IdentityRole
|
||||
{
|
||||
Id = "580b6053-a9a1-4373-8081-b1ae5db82406",
|
||||
Name = "Operator",
|
||||
NormalizedName = "OPERATOR"
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
using CleanArchitecture.Identity.Models;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
|
||||
namespace CleanArchitecture.Identity.Configurations
|
||||
{
|
||||
public class UserConfiguration : IEntityTypeConfiguration<ApplicationUser>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<ApplicationUser> builder)
|
||||
{
|
||||
var hasher = new PasswordHasher<ApplicationUser>();
|
||||
|
||||
builder.HasData(
|
||||
new ApplicationUser()
|
||||
{
|
||||
Id = "b6e00d83-b0e5-4ec3-8935-c52857fc5678",
|
||||
Email = "admin@asarmiento.es",
|
||||
NormalizedEmail = "ADMIN@ASARMIENTO.ES",
|
||||
Nombre = "Admin",
|
||||
Apellidos = "Asarmiento",
|
||||
UserName = "Administrator",
|
||||
NormalizedUserName = "ADMINISTRATOR",
|
||||
PasswordHash = hasher.HashPassword(null, "Password?2024"),
|
||||
EmailConfirmed = true,
|
||||
},
|
||||
new ApplicationUser()
|
||||
{
|
||||
Id = "611f8061-1c0f-4908-9d20-cb4fc0c18c74",
|
||||
Email = "alex@asarmiento.es",
|
||||
NormalizedEmail = "ALEX@ASARMIENTO.ES",
|
||||
Nombre = "Alex",
|
||||
Apellidos = "Sarmiento",
|
||||
UserName = "Alex",
|
||||
NormalizedUserName = "ALEX",
|
||||
PasswordHash = hasher.HashPassword(null, "Password?2024"),
|
||||
EmailConfirmed = true,
|
||||
}
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CleanArchitecture.Identity.Configurations
|
||||
{
|
||||
public class UserRoleConfiguration : IEntityTypeConfiguration<IdentityUserRole<string>>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<IdentityUserRole<string>> builder)
|
||||
{
|
||||
builder.HasData
|
||||
(
|
||||
new IdentityUserRole<string>
|
||||
{
|
||||
RoleId = "26f31fc8-f911-4761-956f-e72c0041c9c9",
|
||||
UserId = "b6e00d83-b0e5-4ec3-8935-c52857fc5678"
|
||||
},
|
||||
new IdentityUserRole<string>
|
||||
{
|
||||
RoleId = "580b6053-a9a1-4373-8081-b1ae5db82406",
|
||||
UserId = "611f8061-1c0f-4908-9d20-cb4fc0c18c74"
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
|
||||
namespace CleanArchitecture.Identity.Models
|
||||
{
|
||||
public class ApplicationUser : IdentityUser
|
||||
{
|
||||
public string Nombre { get; set; } = string.Empty;
|
||||
public string Apellidos { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user