a89580ac70
* #102: Moving Models and constants to their own library * #102: Updated sln file * #102: Updated README to include step install migration tool
35 lines
978 B
C#
35 lines
978 B
C#
using Microsoft.EntityFrameworkCore;
|
|
|
|
using Icarus.Models;
|
|
|
|
namespace Icarus.Database.Contexts;
|
|
|
|
public class CoverArtContext : DbContext
|
|
{
|
|
#region Properties
|
|
public DbSet<CoverArt>? CoverArtImages { get; set; }
|
|
#endregion
|
|
|
|
public CoverArtContext(DbContextOptions<CoverArtContext> options) : base(options) { }
|
|
public CoverArtContext(string connString) : base(new DbContextOptionsBuilder<CoverArtContext>()
|
|
.UseMySQL(connString).Options)
|
|
{
|
|
}
|
|
|
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
|
{
|
|
modelBuilder.Entity<CoverArt>()
|
|
.ToTable("CoverArt");
|
|
}
|
|
|
|
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;
|
|
}
|
|
}
|