Added DAL
This commit is contained in:
parent
b2ee3b430a
commit
46b57505ef
2
.gitignore
vendored
2
.gitignore
vendored
@ -2,3 +2,5 @@
|
||||
/website/obj/
|
||||
/unitTests/bin/
|
||||
/unitTests/obj/
|
||||
/DAL/bin/
|
||||
/DAL/obj/
|
||||
|
137
DAL/Contexts/SASGContext.cs
Normal file
137
DAL/Contexts/SASGContext.cs
Normal file
@ -0,0 +1,137 @@
|
||||
using DAL.Models;
|
||||
using DAL.Models.Audits;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace DAL.Contexts
|
||||
{
|
||||
public class SASGContext : DbContext
|
||||
{
|
||||
public SASGContext()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public SASGContext(DbContextOptions<SASGContext> options) : base(options)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public virtual DbSet<Color> colors { get; set; }
|
||||
public virtual DbSet<Event> events { get; set; }
|
||||
public virtual DbSet<Grant> grants { get; set; }
|
||||
public virtual DbSet<Image> images { get; set; }
|
||||
public virtual DbSet<Permission> permissions { get; set; }
|
||||
public virtual DbSet<SavedEvent> savedEvents { get; set; }
|
||||
public virtual DbSet<User> users { get; set; }
|
||||
public virtual DbSet<AuditColor> auditColors { get; set; }
|
||||
public virtual DbSet<AuditEvent> auditEvents { get; set; }
|
||||
public virtual DbSet<AuditGrant> auditGrants { get; set; }
|
||||
public virtual DbSet<AuditImage> auditImages { get; set; }
|
||||
public virtual DbSet<AuditPermission> auditPermissions { get; set; }
|
||||
public virtual DbSet<AuditSavedEvent> auditSavedEvents { get; set; }
|
||||
public virtual DbSet<AuditUser> auditUsers { get; set; }
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder builder)
|
||||
{
|
||||
builder.Entity<Color>(entity =>
|
||||
{
|
||||
entity.HasOne(e => e.updaterRelation).WithMany()
|
||||
.HasForeignKey(e => e.updater).HasConstraintName("colors_users_id_fk");
|
||||
});
|
||||
|
||||
builder.Entity<Event>(entity =>
|
||||
{
|
||||
entity.HasOne(e => e.bgColorRelation).WithMany()
|
||||
.HasForeignKey(e => e.bgColorId).HasConstraintName("events_colors_id_fk");
|
||||
entity.HasOne(e => e.fgColorRelation).WithMany()
|
||||
.HasForeignKey(e => e.fgColorId).HasConstraintName("events_colors_id_fk_2");
|
||||
entity.HasOne(e => e.imageRelation).WithMany()
|
||||
.HasForeignKey(e => e.imageId).HasConstraintName("events_images_id_fk");
|
||||
entity.HasOne(e => e.savedEventRelation).WithMany()
|
||||
.HasForeignKey(e => e.savedEventId).HasConstraintName("events_savedEvent_id_fk");
|
||||
entity.HasOne(e => e.updaterRelation).WithMany()
|
||||
.HasForeignKey(e => e.updater).HasConstraintName("events_users_id_fk");
|
||||
});
|
||||
|
||||
builder.Entity<Grant>(entity =>
|
||||
{
|
||||
entity.HasOne(e => e.permissionRelation).WithMany()
|
||||
.HasForeignKey(e => e.permissionId).HasConstraintName("grants_permissions_id_fk");
|
||||
entity.HasOne(e => e.updaterRelation).WithMany()
|
||||
.HasForeignKey(e => e.updater).HasConstraintName("grants_users_id_fk");
|
||||
});
|
||||
|
||||
builder.Entity<Image>(entity =>
|
||||
{
|
||||
entity.HasOne(e => e.updaterRelation).WithMany()
|
||||
.HasForeignKey(e => e.updater).HasConstraintName("grants_users_id_fk");
|
||||
});
|
||||
|
||||
builder.Entity<Permission>(entity =>
|
||||
{
|
||||
entity.HasOne(e => e.updaterRelation).WithMany()
|
||||
.HasForeignKey(e => e.updater).HasConstraintName("grants_users_id_fk");
|
||||
});
|
||||
|
||||
builder.Entity<SavedEvent>(entity =>
|
||||
{
|
||||
entity.HasOne(e => e.bgColorRelation).WithMany()
|
||||
.HasForeignKey(e => e.bgColorId).HasConstraintName("events_colors_id_fk");
|
||||
entity.HasOne(e => e.fgColorRelation).WithMany()
|
||||
.HasForeignKey(e => e.fgColorId).HasConstraintName("events_colors_id_fk_2");
|
||||
entity.HasOne(e => e.imageRelation).WithMany()
|
||||
.HasForeignKey(e => e.imageId).HasConstraintName("events_images_id_fk");
|
||||
entity.HasOne(e => e.updaterRelation).WithMany()
|
||||
.HasForeignKey(e => e.updater).HasConstraintName("events_users_id_fk");
|
||||
});
|
||||
|
||||
builder.Entity<User>(entity =>
|
||||
{
|
||||
entity.HasOne(e => e.updaterRelation).WithMany()
|
||||
.HasForeignKey(e => e.updater).HasConstraintName("events_users_id_fk");
|
||||
});
|
||||
|
||||
builder.Entity<AuditColor>(entity =>
|
||||
{
|
||||
entity.HasOne<Color>().WithMany(e => e.audits)
|
||||
.HasForeignKey(e => e.id).IsRequired();
|
||||
});
|
||||
|
||||
builder.Entity<AuditEvent>(entity =>
|
||||
{
|
||||
entity.HasOne<Event>().WithMany(e => e.audits)
|
||||
.HasForeignKey(e => e.id).IsRequired();
|
||||
});
|
||||
|
||||
builder.Entity<AuditGrant>(entity =>
|
||||
{
|
||||
entity.HasOne<Grant>().WithMany(e => e.audits)
|
||||
.HasForeignKey(e => e.id).IsRequired();
|
||||
});
|
||||
|
||||
builder.Entity<AuditImage>(entity =>
|
||||
{
|
||||
entity.HasOne<Image>().WithMany(e => e.audits)
|
||||
.HasForeignKey(e => e.id).IsRequired();
|
||||
});
|
||||
|
||||
builder.Entity<AuditPermission>(entity =>
|
||||
{
|
||||
entity.HasOne<Permission>().WithMany(e => e.audits)
|
||||
.HasForeignKey(e => e.id).IsRequired();
|
||||
});
|
||||
|
||||
builder.Entity<AuditSavedEvent>(entity =>
|
||||
{
|
||||
entity.HasOne<SavedEvent>().WithMany(e => e.audits)
|
||||
.HasForeignKey(e => e.id).IsRequired();
|
||||
});
|
||||
|
||||
builder.Entity<AuditUser>(entity =>
|
||||
{
|
||||
entity.HasOne<User>().WithMany(e => e.audits)
|
||||
.HasForeignKey(e => e.id).IsRequired();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
18
DAL/DAL.csproj
Normal file
18
DAL/DAL.csproj
Normal file
@ -0,0 +1,18 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.0-preview.3.24172.4" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="9.0.0-preview.3.24172.4">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="MySql.EntityFrameworkCore" Version="8.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
35
DAL/Models/Audits/AuditColor.cs
Normal file
35
DAL/Models/Audits/AuditColor.cs
Normal file
@ -0,0 +1,35 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace DAL.Models.Audits
|
||||
{
|
||||
[Index("id", Name = "audit_colors_colors_id_fk")]
|
||||
[Table("audit_colors")]
|
||||
[Keyless]
|
||||
public class AuditColor
|
||||
{
|
||||
[Column("id")]
|
||||
public ulong id { get; set; }
|
||||
|
||||
[Column("red")]
|
||||
public byte red { get; set; }
|
||||
|
||||
[Column("blue")]
|
||||
public byte blue { get; set; }
|
||||
|
||||
[Column("green")]
|
||||
public byte green { get; set; }
|
||||
|
||||
[Column("name")]
|
||||
[MaxLength(64)]
|
||||
public string name { get; set; } = null!;
|
||||
|
||||
[Column("updated")]
|
||||
[DataType("datetime")]
|
||||
public DateTime updated { get; set; }
|
||||
|
||||
[Column("updater")]
|
||||
public ulong updater { get; set; }
|
||||
}
|
||||
}
|
41
DAL/Models/Audits/AuditEvent.cs
Normal file
41
DAL/Models/Audits/AuditEvent.cs
Normal file
@ -0,0 +1,41 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace DAL.Models.Audits
|
||||
{
|
||||
[Table("audit_event")]
|
||||
[Index("id", Name = "audit_events_events_id_fk")]
|
||||
[Keyless]
|
||||
public class AuditEvent
|
||||
{
|
||||
[Column("id")]
|
||||
public ulong id { get; set; }
|
||||
|
||||
[Column("savedEventId")]
|
||||
public ulong savedEventId { get; set; }
|
||||
|
||||
[Column("name")]
|
||||
[MaxLength(64)]
|
||||
public string? name { get; set; }
|
||||
|
||||
[Column("bgColorId")]
|
||||
public ulong? bgColorId { get; set; }
|
||||
|
||||
[Column("fgColorId")]
|
||||
public ulong? fgColorId { get; set; }
|
||||
|
||||
[Column("imageId")]
|
||||
public ulong? imageId { get; set; }
|
||||
|
||||
[Column("hidden")]
|
||||
public bool hidden { get; set; }
|
||||
|
||||
[Column("updated")]
|
||||
[DataType("datetime")]
|
||||
public DateTime updated { get; set; }
|
||||
|
||||
[Column("updater")]
|
||||
public ulong updater { get; set; }
|
||||
}
|
||||
}
|
29
DAL/Models/Audits/AuditGrant.cs
Normal file
29
DAL/Models/Audits/AuditGrant.cs
Normal file
@ -0,0 +1,29 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace DAL.Models.Audits
|
||||
{
|
||||
[Table("audit_grants")]
|
||||
[Index("id", Name = "audit_grants_grants_id_fk")]
|
||||
[Keyless]
|
||||
public class AuditGrant
|
||||
{
|
||||
[Column("id")]
|
||||
public ulong id { get; set; }
|
||||
|
||||
[Column("name")]
|
||||
[MaxLength(128)]
|
||||
public string name { get; set; } = null!;
|
||||
|
||||
[Column("permissionId")]
|
||||
public ulong permissionId { get; set; }
|
||||
|
||||
[Column("updated")]
|
||||
[DataType("updated")]
|
||||
public DateTime updated { get; set; }
|
||||
|
||||
[Column("updater")]
|
||||
public ulong updater { get; set; }
|
||||
}
|
||||
}
|
31
DAL/Models/Audits/AuditImage.cs
Normal file
31
DAL/Models/Audits/AuditImage.cs
Normal file
@ -0,0 +1,31 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace DAL.Models.Audits
|
||||
{
|
||||
[Table("audit_images")]
|
||||
[Index("id", Name = "audit_images_images_id_fk")]
|
||||
[Keyless]
|
||||
public class AuditImage
|
||||
{
|
||||
[Key]
|
||||
[Column("id")]
|
||||
public ulong id { get; set; }
|
||||
|
||||
[Column("name")]
|
||||
[MaxLength(64)]
|
||||
public string name { get; set; } = null!;
|
||||
|
||||
[Column("filename")]
|
||||
[MaxLength(128)]
|
||||
public string filename { get; set; } = null!;
|
||||
|
||||
[Column("updated")]
|
||||
[DataType("datetime")]
|
||||
public DateTime updated { get; set; }
|
||||
|
||||
[Column("updater")]
|
||||
public ulong updater { get; set; }
|
||||
}
|
||||
}
|
26
DAL/Models/Audits/AuditPermission.cs
Normal file
26
DAL/Models/Audits/AuditPermission.cs
Normal file
@ -0,0 +1,26 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace DAL.Models.Audits
|
||||
{
|
||||
[Table("audit_permissions")]
|
||||
[Index("id", Name = "audit_permissions_permissions_id_fk")]
|
||||
[Keyless]
|
||||
public class AuditPermission
|
||||
{
|
||||
[Column("id")]
|
||||
public ulong id { get; set; }
|
||||
|
||||
[Column("name")]
|
||||
[MaxLength(64)]
|
||||
public string name { get; set; } = null!;
|
||||
|
||||
[Column("updated")]
|
||||
[DataType("datetime")]
|
||||
public DateTime updated { get; set; }
|
||||
|
||||
[Column("updater")]
|
||||
public ulong updater { get; set; }
|
||||
}
|
||||
}
|
35
DAL/Models/Audits/AuditSavedEvent.cs
Normal file
35
DAL/Models/Audits/AuditSavedEvent.cs
Normal file
@ -0,0 +1,35 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace DAL.Models.Audits
|
||||
{
|
||||
[Table("audit_savedEvents")]
|
||||
[Index("id", Name = "audit_savedEvents_savedEvents_id_fk")]
|
||||
[Keyless]
|
||||
public class AuditSavedEvent
|
||||
{
|
||||
[Column("id")]
|
||||
public ulong id { get; set; }
|
||||
|
||||
[Column("name")]
|
||||
[MaxLength(64)]
|
||||
public string name { get; set; } = null!;
|
||||
|
||||
[Column("bgColorId")]
|
||||
public ulong bgColorId { get; set; }
|
||||
|
||||
[Column("fgColorId")]
|
||||
public ulong fgColorId { get; set; }
|
||||
|
||||
[Column("imageId")]
|
||||
public ulong? imageId { get; set; }
|
||||
|
||||
[Column("updated")]
|
||||
[DataType("datetime")]
|
||||
public DateTime updated { get; set; }
|
||||
|
||||
[Column("updater")]
|
||||
public ulong updater { get; set; }
|
||||
}
|
||||
}
|
40
DAL/Models/Audits/AuditUser.cs
Normal file
40
DAL/Models/Audits/AuditUser.cs
Normal file
@ -0,0 +1,40 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace DAL.Models.Audits
|
||||
{
|
||||
[Table("audit_users")]
|
||||
[Index("id", Name = "audit_users_users_id_fk")]
|
||||
[Keyless]
|
||||
public class AuditUser
|
||||
{
|
||||
[Column("id")]
|
||||
public ulong id { get; set; }
|
||||
|
||||
[Column("firstName")]
|
||||
[MaxLength(64)]
|
||||
public string firstName { get; set; } = null!;
|
||||
|
||||
[Column("lastName")]
|
||||
[MaxLength(64)]
|
||||
public string lastName { get; set; } = null!;
|
||||
|
||||
[Column("phoneNumber")]
|
||||
public ulong phoneNumber { get; set; }
|
||||
|
||||
[Column("hashingType")]
|
||||
[MaxLength(64)]
|
||||
public HashingType hashingType { get; set; }
|
||||
|
||||
[Column("permissionId")]
|
||||
public ulong permissionId { get; set; }
|
||||
|
||||
[Column("updated")]
|
||||
[DataType("datetime")]
|
||||
public DateTime updated { get; set; }
|
||||
|
||||
[Column("updater")]
|
||||
public ulong updater { get; set; }
|
||||
}
|
||||
}
|
40
DAL/Models/Color.cs
Normal file
40
DAL/Models/Color.cs
Normal file
@ -0,0 +1,40 @@
|
||||
using DAL.Models.Audits;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace DAL.Models
|
||||
{
|
||||
[Table("colors")]
|
||||
[Index("updater", Name = "colors_users_id_fk")]
|
||||
public class Color
|
||||
{
|
||||
[Key]
|
||||
[Column("id")]
|
||||
public ulong id { get; set; }
|
||||
|
||||
[Column("red")]
|
||||
public byte red { get; set; }
|
||||
|
||||
[Column("blue")]
|
||||
public byte blue { get; set; }
|
||||
|
||||
[Column("green")]
|
||||
public byte green { get; set; }
|
||||
|
||||
[Column("name")]
|
||||
[MaxLength(64)]
|
||||
public string name { get; set; } = null!;
|
||||
|
||||
[Column("updated")]
|
||||
[DataType("datetime")]
|
||||
public DateTime updated { get; set; }
|
||||
|
||||
[Column("updater")]
|
||||
public ulong updater { get; set; }
|
||||
|
||||
public User updaterRelation { get; set; } = null!;
|
||||
|
||||
public ICollection<AuditColor> audits { get; set; } = new List<AuditColor>();
|
||||
}
|
||||
}
|
54
DAL/Models/Event.cs
Normal file
54
DAL/Models/Event.cs
Normal file
@ -0,0 +1,54 @@
|
||||
using DAL.Models.Audits;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace DAL.Models
|
||||
{
|
||||
[Table("events")]
|
||||
[Index("updater", Name = "event_users_id_fk")]
|
||||
[Index("bgColorId", Name = "events_colors_id_fk")]
|
||||
[Index("fgColorId", Name = "events_colors_id_fk_2")]
|
||||
[Index("imageId", Name = "events_images_id_fk")]
|
||||
[Index("savedEventId", Name = "events_savedEvents_id_fk")]
|
||||
public class Event
|
||||
{
|
||||
[Key]
|
||||
[Column("id")]
|
||||
public ulong id { get; set; }
|
||||
|
||||
[Column("savedEventId")]
|
||||
public ulong savedEventId { get; set; }
|
||||
|
||||
[Column("name")]
|
||||
[MaxLength(64)]
|
||||
public string? name { get; set; }
|
||||
|
||||
[Column("bgColorId")]
|
||||
public ulong? bgColorId { get; set; }
|
||||
|
||||
[Column("fgColorId")]
|
||||
public ulong? fgColorId { get; set; }
|
||||
|
||||
[Column("imageId")]
|
||||
public ulong? imageId { get; set; }
|
||||
|
||||
[Column("hidden")]
|
||||
public bool hidden { get; set; }
|
||||
|
||||
[Column("updated")]
|
||||
[DataType("datetime")]
|
||||
public DateTime updated { get; set; }
|
||||
|
||||
[Column("updater")]
|
||||
public ulong updater { get; set; }
|
||||
|
||||
public User updaterRelation { get; set; } = null!;
|
||||
public SavedEvent savedEventRelation { get; set; } = null!;
|
||||
public Color? bgColorRelation { get; set; }
|
||||
public Color? fgColorRelation { get; set; }
|
||||
public Image? imageRelation { get; set; }
|
||||
|
||||
public ICollection<AuditEvent> audits { get; set; } = new List<AuditEvent>();
|
||||
}
|
||||
}
|
37
DAL/Models/Grant.cs
Normal file
37
DAL/Models/Grant.cs
Normal file
@ -0,0 +1,37 @@
|
||||
using DAL.Models.Audits;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace DAL.Models
|
||||
{
|
||||
[Table("grants")]
|
||||
[Index("updater", Name = "grants_users_id_fk")]
|
||||
[Index("permissionId", Name = "grants_permissions_id_fk")]
|
||||
[Index("updater", Name = "grants_users_id_fk")]
|
||||
public class Grant
|
||||
{
|
||||
[Key]
|
||||
[Column("id")]
|
||||
public ulong id { get; set; }
|
||||
|
||||
[Column("name")]
|
||||
[MaxLength(128)]
|
||||
public string name { get; set; } = null!;
|
||||
|
||||
[Column("permissionId")]
|
||||
public ulong permissionId { get; set; }
|
||||
|
||||
[Column("updated")]
|
||||
[DataType("updated")]
|
||||
public DateTime updated { get; set; }
|
||||
|
||||
[Column("updater")]
|
||||
public ulong updater { get; set; }
|
||||
|
||||
public virtual User updaterRelation { get; set; } = null!;
|
||||
public virtual Permission permissionRelation { get; set; } = null!;
|
||||
|
||||
public ICollection<AuditGrant> audits { get; set; } = new List<AuditGrant>();
|
||||
}
|
||||
}
|
35
DAL/Models/Image.cs
Normal file
35
DAL/Models/Image.cs
Normal file
@ -0,0 +1,35 @@
|
||||
using DAL.Models.Audits;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace DAL.Models
|
||||
{
|
||||
[Table("images")]
|
||||
[Index("updater", Name = "images_users_id_fk")]
|
||||
public class Image
|
||||
{
|
||||
[Key]
|
||||
[Column("id")]
|
||||
public ulong id { get; set; }
|
||||
|
||||
[Column("name")]
|
||||
[MaxLength(64)]
|
||||
public string name { get; set; } = null!;
|
||||
|
||||
[Column("filename")]
|
||||
[MaxLength(128)]
|
||||
public string filename { get; set; } = null!;
|
||||
|
||||
[Column("updated")]
|
||||
[DataType("datetime")]
|
||||
public DateTime updated { get; set; }
|
||||
|
||||
[Column("updater")]
|
||||
public ulong updater { get; set; }
|
||||
|
||||
public virtual User updaterRelation { get; set; } = null!;
|
||||
|
||||
public ICollection<AuditImage> audits { get; set; } = new List<AuditImage>();
|
||||
}
|
||||
}
|
31
DAL/Models/Permission.cs
Normal file
31
DAL/Models/Permission.cs
Normal file
@ -0,0 +1,31 @@
|
||||
using DAL.Models.Audits;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace DAL.Models
|
||||
{
|
||||
[Table("permissions")]
|
||||
[Index("updater", Name = "permissions_users_id_fk")]
|
||||
public class Permission
|
||||
{
|
||||
[Key]
|
||||
[Column("id")]
|
||||
public ulong id { get; set; }
|
||||
|
||||
[Column("name")]
|
||||
[MaxLength(64)]
|
||||
public string name { get; set; } = null!;
|
||||
|
||||
[Column("updated")]
|
||||
[DataType("datetime")]
|
||||
public DateTime updated { get; set; }
|
||||
|
||||
[Column("updater")]
|
||||
public ulong updater { get; set; }
|
||||
|
||||
public virtual User updaterRelation { get; set; } = null!;
|
||||
|
||||
public ICollection<AuditPermission> audits { get; set; } = new List<AuditPermission>();
|
||||
}
|
||||
}
|
46
DAL/Models/SavedEvent.cs
Normal file
46
DAL/Models/SavedEvent.cs
Normal file
@ -0,0 +1,46 @@
|
||||
using DAL.Models.Audits;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace DAL.Models
|
||||
{
|
||||
[Table("savedEvents")]
|
||||
[Index("updater", Name = "savedEvents_users_id_fk")]
|
||||
[Index("fgColorId", Name = "savedEvents_colors_id_fk")]
|
||||
[Index("bgColorId", Name = "savedEvents_colors_id_fk_2")]
|
||||
[Index("imageId", Name = "savedEvents_images_id_fk")]
|
||||
public class SavedEvent
|
||||
{
|
||||
[Key]
|
||||
[Column("id")]
|
||||
public ulong id { get; set; }
|
||||
|
||||
[Column("name")]
|
||||
[MaxLength(64)]
|
||||
public string name { get; set; } = null!;
|
||||
|
||||
[Column("bgColorId")]
|
||||
public ulong bgColorId { get; set; }
|
||||
|
||||
[Column("fgColorId")]
|
||||
public ulong fgColorId { get; set; }
|
||||
|
||||
[Column("imageId")]
|
||||
public ulong? imageId { get; set; }
|
||||
|
||||
[Column("updated")]
|
||||
[DataType("datetime")]
|
||||
public DateTime updated { get; set; }
|
||||
|
||||
[Column("updater")]
|
||||
public ulong updater { get; set; }
|
||||
|
||||
public User updaterRelation { get; set; } = null!;
|
||||
public Color bgColorRelation { get; set; } = null!;
|
||||
public Color fgColorRelation { get; set; } = null!;
|
||||
public Image? imageRelation { get; set; }
|
||||
|
||||
public ICollection<AuditSavedEvent> audits { get; set; } = new List<AuditSavedEvent>();
|
||||
}
|
||||
}
|
61
DAL/Models/User.cs
Normal file
61
DAL/Models/User.cs
Normal file
@ -0,0 +1,61 @@
|
||||
using DAL.Models.Audits;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace DAL.Models
|
||||
{
|
||||
[JsonConverter(typeof(JsonStringEnumConverter))]
|
||||
public enum HashingType
|
||||
{
|
||||
PBKDF2_SHA512_64_210000
|
||||
}
|
||||
|
||||
[Table("users")]
|
||||
[Index("updater", Name = "users_users_id_fk")]
|
||||
[Index("permissionId", Name = "users_permissions_id_fk")]
|
||||
public class User
|
||||
{
|
||||
[Key]
|
||||
[Column("id")]
|
||||
public ulong id { get; set; }
|
||||
|
||||
[Column("firstName")]
|
||||
[MaxLength(64)]
|
||||
public string firstName { get; set; } = null!;
|
||||
|
||||
[Column("lastName")]
|
||||
[MaxLength(64)]
|
||||
public string lastName { get; set; } = null!;
|
||||
|
||||
[Column("phoneNumber")]
|
||||
public ulong phoneNumber { get; set; }
|
||||
|
||||
[Column("password")]
|
||||
[MaxLength(1000)]
|
||||
public string password { get; set; } = null!;
|
||||
|
||||
[Column("salt")]
|
||||
[DataType("blob")]
|
||||
public byte[] salt { get; set; } = null!;
|
||||
|
||||
[Column("hashingType")]
|
||||
[MaxLength(64)]
|
||||
public HashingType hashingType { get; set; }
|
||||
|
||||
[Column("permissionId")]
|
||||
public ulong permissionId { get; set; }
|
||||
|
||||
[Column("updated")]
|
||||
[DataType("datetime")]
|
||||
public DateTime updated { get; set; }
|
||||
|
||||
[Column("updater")]
|
||||
public ulong updater { get; set; }
|
||||
|
||||
public virtual User updaterRelation { get; set; } = null!;
|
||||
|
||||
public ICollection<AuditUser> audits { get; set; } = new List<AuditUser>();
|
||||
}
|
||||
}
|
@ -4,6 +4,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "website", "website\website.
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "unitTests", "unitTests\unitTests.csproj", "{089ACCAD-8117-4C24-9429-56A394AC4734}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DAL", "DAL\DAL.csproj", "{EE2CF24D-1C19-4915-A6BB-7A244F527CE4}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@ -18,5 +20,9 @@ Global
|
||||
{089ACCAD-8117-4C24-9429-56A394AC4734}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{089ACCAD-8117-4C24-9429-56A394AC4734}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{089ACCAD-8117-4C24-9429-56A394AC4734}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{EE2CF24D-1C19-4915-A6BB-7A244F527CE4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{EE2CF24D-1C19-4915-A6BB-7A244F527CE4}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{EE2CF24D-1C19-4915-A6BB-7A244F527CE4}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{EE2CF24D-1C19-4915-A6BB-7A244F527CE4}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
Loading…
x
Reference in New Issue
Block a user