Web Api layout
This commit is contained in:
parent
5619093f41
commit
da6d5576bf
32 changed files with 515 additions and 29 deletions
36
InkForge.Api.Data/ApiDbContext.cs
Normal file
36
InkForge.Api.Data/ApiDbContext.cs
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
using InkForge.Api.Data.Infrastructure;
|
||||
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace InkForge.Api.Data;
|
||||
|
||||
public class ApiDbcontext(
|
||||
DbContextOptions<ApiDbcontext> options
|
||||
) : IdentityDbContext<IdentityUser>(options)
|
||||
{
|
||||
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();
|
||||
});
|
||||
}
|
||||
}
|
||||
16
InkForge.Api.Data/Domain/Workspace.cs
Normal file
16
InkForge.Api.Data/Domain/Workspace.cs
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
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; }
|
||||
}
|
||||
9
InkForge.Api.Data/Infrastructure/WorkspaceEntities.cs
Normal file
9
InkForge.Api.Data/Infrastructure/WorkspaceEntities.cs
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
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>;
|
||||
}
|
||||
17
InkForge.Api.Data/InkForge.Api.Data.csproj
Normal file
17
InkForge.Api.Data/InkForge.Api.Data.csproj
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\shared\InkForge.Data\InkForge.Data.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
Loading…
Add table
Add a link
Reference in a new issue