tsk-76: Added model and context for AccessLevel #108

Merged
kdeng00 merged 14 commits from tsk-76 into master 2025-03-11 21:45:32 -04:00
3 changed files with 8 additions and 6 deletions
Showing only changes of commit 2e723a4bc0 - Show all commits
@@ -1,14 +1,12 @@
using Microsoft.EntityFrameworkCore;
using Icarus.Models;
namespace Icarus.Database.Contexts;
public class AccessLevelContext : DbContext
{
public DbSet<AccessLevel> AccessLevels { get; set; }
public DbSet<Icarus.Models.AccessLevel>? AccessLevels { get; set; }
public AccessLevelContext(DbContextOptions<AccessLevelContext> options) : base(options) { }
public AccessLevelContext(string connString) : base(new DbContextOptionsBuilder<AccessLevelContext>()
.UseMySQL(connString).Options)
{
@@ -18,6 +16,9 @@ public class AccessLevelContext : DbContext
#region Methods
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<Icarus.Models.AccessLevel>().ToTable("AccessLevel");
// modelBuilder.Entity<Icarus.Models.AccessLevel>().Property(m => m.Level).IsRequired(true);
}
#endregion
}
}
+1
View File
@@ -76,6 +76,7 @@ builder.Services.AddDbContext<ArtistContext>(options => options.UseMySQL(connStr
builder.Services.AddDbContext<UserContext>(options => options.UseMySQL(connString!));
builder.Services.AddDbContext<GenreContext>(options => options.UseMySQL(connString!));
builder.Services.AddDbContext<CoverArtContext>(options => options.UseMySQL(connString!));
builder.Services.AddDbContext<AccessLevelContext>(options => options.UseMySQL(connString!));
builder.Services.AddControllers()
.AddNewtonsoftJson();
+1 -1
View File
@@ -8,7 +8,7 @@ public class AccessLevel
[Newtonsoft.Json.JsonProperty("id")]
public int Id { get; set; }
[Newtonsoft.Json.JsonProperty("level")]
public string Level { get; set; }
public string? Level { get; set; }
[Newtonsoft.Json.JsonProperty("song_id")]
public int SongId { get; set; }
#endregion