[CHANGE] Reworked entities and contexts

This commit is contained in:
max
2025-08-18 00:46:40 +02:00
parent a62eeb727a
commit f784000393
18 changed files with 23 additions and 78 deletions

View File

@@ -7,11 +7,6 @@ namespace Manager.App;
public static class DependencyInjection public static class DependencyInjection
{ {
public static WebApplicationBuilder InjectDependencies(this WebApplicationBuilder builder)
{
return builder;
}
public static void SetupLogging(this WebApplicationBuilder builder) public static void SetupLogging(this WebApplicationBuilder builder)
{ {
var isDevelopment = builder.Environment.IsDevelopment(); var isDevelopment = builder.Environment.IsDevelopment();

View File

@@ -21,8 +21,13 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\Manager.Data\Manager.Data.csproj" />
<ProjectReference Include="..\Manager.Shared\Manager.Shared.csproj" /> <ProjectReference Include="..\Manager.Shared\Manager.Shared.csproj" />
<ProjectReference Include="..\Manager.YouTube\Manager.YouTube.csproj" /> <ProjectReference Include="..\Manager.YouTube\Manager.YouTube.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<Folder Include="Services\" />
</ItemGroup>
</Project> </Project>

View File

@@ -10,6 +10,9 @@ builder.Services.AddRazorComponents()
builder.SetupLogging(); builder.SetupLogging();
/* App setup */
/* MudBlazor */ /* MudBlazor */
builder.Services.AddMudServices(); builder.Services.AddMudServices();

View File

@@ -1,33 +0,0 @@
using Manager.Data.Models.ApplicationContext;
using Microsoft.EntityFrameworkCore;
namespace Manager.Data.Contexts;
public sealed class ApplicationDbContext : DbContext
{
public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options) : base(options)
{
ChangeTracker.QueryTrackingBehavior = QueryTrackingBehavior.NoTracking;
ChangeTracker.LazyLoadingEnabled = false;
}
public DbSet<SettingsGroupModel> SettingsGroups { get; set; }
public DbSet<SettingsModel> Settings { get; set; }
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<SettingsGroupModel>(sg =>
{
sg.ToTable("settings_groups");
sg.HasKey(x => x.Id);
});
modelBuilder.Entity<SettingsModel>(settingsEntity =>
{
settingsEntity.ToTable("settings");
settingsEntity.HasKey(x => x.Key);
});
base.OnModelCreating(modelBuilder);
}
}

View File

@@ -1,5 +1,5 @@
using Manager.Data.Models.LibraryContext; using Manager.Data.Entities.LibraryContext;
using Manager.Data.Models.LibraryContext.Join; using Manager.Data.Entities.LibraryContext.Join;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
namespace Manager.Data.Contexts; namespace Manager.Data.Contexts;

View File

@@ -1,2 +0,0 @@
namespace Manager.Data;

View File

@@ -1,4 +1,4 @@
namespace Manager.Data.Models; namespace Manager.Data.Entities;
public abstract class DateTimeBase public abstract class DateTimeBase
{ {

View File

@@ -1,6 +1,6 @@
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
namespace Manager.Data.Models.LibraryContext; namespace Manager.Data.Entities.LibraryContext;
public class CaptionEntity public class CaptionEntity
{ {

View File

@@ -1,6 +1,6 @@
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
namespace Manager.Data.Models.LibraryContext; namespace Manager.Data.Entities.LibraryContext;
public class ChannelEntity : DateTimeBase public class ChannelEntity : DateTimeBase
{ {

View File

@@ -1,6 +1,6 @@
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
namespace Manager.Data.Models.LibraryContext; namespace Manager.Data.Entities.LibraryContext;
public class ClientAccountEntity : DateTimeBase public class ClientAccountEntity : DateTimeBase
{ {

View File

@@ -1,6 +1,6 @@
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
namespace Manager.Data.Models.LibraryContext; namespace Manager.Data.Entities.LibraryContext;
public class HttpCookieEntity : DateTimeBase public class HttpCookieEntity : DateTimeBase
{ {

View File

@@ -1,6 +1,6 @@
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
namespace Manager.Data.Models.LibraryContext.Join; namespace Manager.Data.Entities.LibraryContext.Join;
public class PlaylistMedia public class PlaylistMedia
{ {

View File

@@ -1,7 +1,7 @@
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using Manager.Data.Models.LibraryContext.Join; using Manager.Data.Entities.LibraryContext.Join;
namespace Manager.Data.Models.LibraryContext; namespace Manager.Data.Entities.LibraryContext;
public class MediaEntity : DateTimeBase public class MediaEntity : DateTimeBase
{ {

View File

@@ -1,6 +1,6 @@
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
namespace Manager.Data.Models.LibraryContext; namespace Manager.Data.Entities.LibraryContext;
public class MediaFormatEntity public class MediaFormatEntity
{ {

View File

@@ -1,7 +1,7 @@
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using Manager.Data.Models.LibraryContext.Join; using Manager.Data.Entities.LibraryContext.Join;
namespace Manager.Data.Models.LibraryContext; namespace Manager.Data.Entities.LibraryContext;
public class PlaylistEntity : DateTimeBase public class PlaylistEntity : DateTimeBase
{ {

View File

@@ -17,6 +17,8 @@
<ItemGroup> <ItemGroup>
<Folder Include="Migrations\" /> <Folder Include="Migrations\" />
<Folder Include="Models\" />
<Folder Include="Services\" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@@ -1,7 +0,0 @@
namespace Manager.Data.Models.ApplicationContext;
public record SettingsGroupModel
{
public required Guid Id { get; set; }
public required string Name { get; set; }
}

View File

@@ -1,18 +0,0 @@
using System.ComponentModel.DataAnnotations;
namespace Manager.Data.Models.ApplicationContext;
public class SettingsModel
{
[MaxLength(DataConstants.DbContext.DefaultDbStringSize)]
public required string Key { get; set; }
[MaxLength(DataConstants.DbContext.DefaultDbStringSize)]
public required string Name { get; set; }
[MaxLength(DataConstants.DbContext.DefaultDbDescriptionStringSize)]
public required string Description { get; set; }
public Guid? GroupId { get; set; }
[MaxLength(DataConstants.DbContext.DefaultDbStringSize)]
public string ValueType { get; set; } = nameof(String);
public object? Value { get; set; }
public object? DefaultValue { get; set; }
}