WIP
This commit is contained in:
44
src/api/MicCheck.Api/Data/Configurations/UserProjectPermissionConfiguration.cs
Normal file → Executable file
44
src/api/MicCheck.Api/Data/Configurations/UserProjectPermissionConfiguration.cs
Normal file → Executable file
@@ -1,22 +1,22 @@
|
||||
using MicCheck.Api.Common.Security.Authorization;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
|
||||
namespace MicCheck.Api.Data.Configurations;
|
||||
|
||||
public class UserProjectPermissionConfiguration : IEntityTypeConfiguration<UserProjectPermission>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<UserProjectPermission> builder)
|
||||
{
|
||||
builder.HasKey(p => new { p.UserId, p.ProjectId });
|
||||
|
||||
builder.Property(p => p.Permissions)
|
||||
.HasConversion(
|
||||
v => string.Join(',', v.Select(p => p.ToString())),
|
||||
v => string.IsNullOrEmpty(v)
|
||||
? new List<ProjectPermission>()
|
||||
: v.Split(',', StringSplitOptions.RemoveEmptyEntries)
|
||||
.Select(Enum.Parse<ProjectPermission>)
|
||||
.ToList());
|
||||
}
|
||||
}
|
||||
using MicCheck.Api.Common.Security.Authorization;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
|
||||
namespace MicCheck.Api.Data.Configurations;
|
||||
|
||||
public class UserProjectPermissionConfiguration : IEntityTypeConfiguration<UserProjectPermission>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<UserProjectPermission> builder)
|
||||
{
|
||||
builder.HasKey(p => new { p.UserId, p.ProjectId });
|
||||
|
||||
builder.Property(p => p.Permissions)
|
||||
.HasConversion(
|
||||
v => string.Join(',', v.Select(p => p.ToString())),
|
||||
v => string.IsNullOrEmpty(v)
|
||||
? new List<ProjectPermission>()
|
||||
: v.Split(',', StringSplitOptions.RemoveEmptyEntries)
|
||||
.Select(Enum.Parse<ProjectPermission>)
|
||||
.ToList());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user