This commit is contained in:
Jöran Malek 2024-04-05 12:31:34 +02:00
parent 4c2b5cca93
commit 43b4d50e43
28 changed files with 674 additions and 249 deletions

View file

@ -1,5 +1,3 @@
using InkForge.Api.Data.Infrastructure;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
@ -12,25 +10,15 @@ public class ApiDbcontext(
{
public DbSet<WorkspaceEntity> Workspaces { get; set; } = default!;
public DbSet<WorkspaceVersionEntity> WorkspaceVersions { get; set; } = default!;
protected override void OnModelCreating(ModelBuilder builder)
{
base.OnModelCreating(builder);
builder.Entity<WorkspaceEntity>(options =>
{
options.OwnsOne(m => m.Value);
options.HasKey(m => m.Id);
});
builder.Entity<WorkspaceVersionEntity>(options =>
{
options.OwnsOne(m => m.Value);
options.HasKey(m => m.Version);
options.HasIndex(nameof(WorkspaceVersionEntity.Id), nameof(WorkspaceVersionEntity.Version)).IsUnique();
});
}
}

View file

@ -1,16 +0,0 @@
using Microsoft.AspNetCore.Identity;
namespace InkForge.Api.Data.Domain;
public class Workspace
{
public string Name { get; set; } = default!;
public DateTimeOffset Created { get; set; }
public IdentityUser Owner { get; set; } = default!;
public DateTimeOffset Updated { get; set; }
public DateTimeOffset? Deleted { get; set; }
}

View file

@ -1,9 +0,0 @@
using InkForge.Api.Data.Domain;
using InkForge.Data;
namespace InkForge.Api.Data.Infrastructure
{
public class WorkspaceEntity : Entity<Workspace, int>;
public class WorkspaceVersionEntity : VersionedEntity<Workspace, int>;
}

View file

@ -0,0 +1,21 @@
using InkForge.Data;
using Microsoft.AspNetCore.Identity;
namespace InkForge.Api.Data
{
public class Workspace
{
public DateTimeOffset Created { get; set; }
public DateTimeOffset? Deleted { get; set; }
public string Name { get; set; } = default!;
public IdentityUser Owner { get; set; } = default!;
public DateTimeOffset Updated { get; set; }
}
public class WorkspaceEntity : Entity<Workspace, int>;
}