using GeoRitmMover.Mover.Data.EntityConfigurations;

using Microsoft.EntityFrameworkCore;

namespace GeoRitmMover.Mover.Data;

/// <summary>
/// Контекст БД для сопоставления идентификаторов.
/// </summary>
/// <param name="options"></param>
public class MoverDbContext(DbContextOptions<MoverDbContext> options) : DbContext(options)
{
	public required DbSet<AssetMap> Assets { get; set; }
	public required DbSet<AssetGroupMap> Groups { get; set; }
	public required DbSet<AreaMap> Areas { get; set; }
	public required DbSet<ZoneMap> Zones { get; set; }
	public required DbSet<PhotoMap> Photos { get; set; }
	public required DbSet<EventCodeMap> EventCodes { get; set; }
	public required DbSet<UserMap> Users { get; set; }
	public required DbSet<AccessMap> Accesses { get; set; }

	protected override void OnModelCreating(ModelBuilder modelBuilder)
	{
		_ = modelBuilder.ApplyConfiguration(new AssetGroupMapEntityConfiguration());
		_ = modelBuilder.ApplyConfiguration(new AssetMapEntityConfiguration());
		_ = modelBuilder.ApplyConfiguration(new AreaMapEntityConfiguration());
		_ = modelBuilder.ApplyConfiguration(new ZoneMapEntityConfiguration());
		_ = modelBuilder.ApplyConfiguration(new PhotoMapEntityConfiguration());
		_ = modelBuilder.ApplyConfiguration(new EventCodeMapEntityConfiguration());
		_ = modelBuilder.ApplyConfiguration(new UserMapEntityConfiguration());
		_ = modelBuilder.ApplyConfiguration(new AccessMapEntityConfiguration());
	}
}
