Add authentication and authorization (#21)
Reviewed-on: #21
This commit was merged in pull request #21.
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
using GameIdeas.Shared.Model;
|
||||
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace GameIdeas.WebAPI.Context;
|
||||
|
||||
public class GameIdeasContext : DbContext
|
||||
public class GameIdeasContext : IdentityDbContext<User>
|
||||
{
|
||||
public GameIdeasContext(DbContextOptions<GameIdeasContext> option)
|
||||
: base(option)
|
||||
@@ -12,7 +13,6 @@ public class GameIdeasContext : DbContext
|
||||
AppContext.SetSwitch("Npgsql.DisableDateTimeInfinityConversions", true);
|
||||
}
|
||||
|
||||
public virtual DbSet<User> Users { get; set; } = null!;
|
||||
public virtual DbSet<Developer> Developers { get; set; } = null!;
|
||||
public virtual DbSet<Platform> Platforms { get; set; } = null!;
|
||||
public virtual DbSet<Property> Properties { get; set; } = null!;
|
||||
@@ -27,28 +27,51 @@ public class GameIdeasContext : DbContext
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
modelBuilder.Entity<User>(entity => {
|
||||
entity.ToTable("User");
|
||||
modelBuilder.Entity<Developer>(entity => {
|
||||
entity.ToTable("Developer");
|
||||
|
||||
entity.Property(e => e.Id)
|
||||
.UseIdentityByDefaultColumn()
|
||||
.HasIdentityOptions(startValue: 100000);
|
||||
entity.HasIndex(e => e.Name)
|
||||
.IsUnique();
|
||||
});
|
||||
|
||||
modelBuilder.Entity<Developer>(entity => entity.ToTable("Developer"));
|
||||
modelBuilder.Entity<Platform>(entity => {
|
||||
entity.ToTable("Platform");
|
||||
|
||||
modelBuilder.Entity<Platform>(entity => entity.ToTable("Platform"));
|
||||
entity.HasIndex(e => e.Label)
|
||||
.IsUnique();
|
||||
});
|
||||
|
||||
modelBuilder.Entity<Property>(entity => entity.ToTable("Property"));
|
||||
modelBuilder.Entity<Property>(entity =>
|
||||
{
|
||||
entity.ToTable("Property");
|
||||
|
||||
entity.HasIndex(e => e.Label)
|
||||
.IsUnique();
|
||||
});
|
||||
|
||||
modelBuilder.Entity<Publisher>(entity => entity.ToTable("Publisher"));
|
||||
modelBuilder.Entity<Publisher>(entity =>
|
||||
{
|
||||
entity.ToTable("Publisher");
|
||||
|
||||
modelBuilder.Entity<Tag>(entity => entity.ToTable("Tag"));
|
||||
entity.HasIndex(e => e.Name)
|
||||
.IsUnique();
|
||||
});
|
||||
|
||||
modelBuilder.Entity<Tag>(entity =>
|
||||
{
|
||||
entity.ToTable("Tag");
|
||||
|
||||
entity.HasIndex(e => e.Label)
|
||||
.IsUnique();
|
||||
});
|
||||
|
||||
modelBuilder.Entity<Game>(entity =>
|
||||
{
|
||||
entity.ToTable("Game");
|
||||
|
||||
entity.HasIndex(e => e.Title)
|
||||
.IsUnique();
|
||||
|
||||
entity.HasIndex(e => e.CreationUserId);
|
||||
|
||||
entity.HasIndex(e => e.ModificationUserId);
|
||||
|
||||
Reference in New Issue
Block a user