using Microsoft.EntityFrameworkCore; using Icarus.Models; namespace Icarus.Database.Contexts; public class CoverArtContext : DbContext { #region Properties public DbSet? CoverArtImages { get; set; } #endregion public CoverArtContext(DbContextOptions options) : base(options) { } public CoverArtContext(string connString) : base(new DbContextOptionsBuilder() .UseMySQL(connString).Options) { } protected override void OnModelCreating(ModelBuilder modelBuilder) { modelBuilder.Entity() .ToTable("CoverArt"); modelBuilder.Entity(entity => { entity.HasKey(e => e.Id); entity.Property(e => e.Id) .HasColumnType("binary(16)"); }); } public CoverArt RetrieveRecord(CoverArt cover) { return CoverArtImages!.FirstOrDefault(cov => cov.Id == cover.Id)!; } public bool DoesRecordExist(CoverArt cover) { return CoverArtImages!.FirstOrDefault(cov => cov.Id == cover.Id) != null ? true : false; } }