WIP: refactor

This commit is contained in:
Michał Zieliski
2024-06-18 19:40:16 +02:00
parent c2a98e0386
commit a0a228f86d
24 changed files with 1415 additions and 1654 deletions

View File

@@ -1,37 +1,35 @@
using Microsoft.EntityFrameworkCore;
using System.Collections.Generic;
using WebAPI.Models;
namespace WebAPI
namespace WebAPI;
public class AppDbContext : DbContext
{
public class AppDbContext : DbContext
public DbSet<User> Users { get; init; }
public DbSet<Layer> Layers { get; init; }
public DbSet<Record> Records { get; init; }
public DbSet<ProcessSource> ProcessSources { get; init; }
public AppDbContext(DbContextOptions<AppDbContext> options) : base(options)
{
public DbSet<User> Users { get; init; }
public DbSet<Layer> Layers { get; init; }
public DbSet<Record> Records { get; init; }
public DbSet<ProcessSource> ProcessSources { get; init; }
}
public AppDbContext(DbContextOptions<AppDbContext> options) : base(options)
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<ProcessSource>().HasKey(x => new
{
}
x.LayerId,
x.SourceId
});
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<ProcessSource>().HasKey(x => new
{
x.LayerId,
x.SourceId
});
}
private static readonly LoggerFactory MyLoggerFactory =
new(new[] {
new Microsoft.Extensions.Logging.Debug.DebugLoggerProvider()
private static readonly LoggerFactory MyLoggerFactory =
new(new[] {
new Microsoft.Extensions.Logging.Debug.DebugLoggerProvider()
});
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder.UseLoggerFactory(MyLoggerFactory);
}
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder.UseLoggerFactory(MyLoggerFactory);
}
}
}