Files
icarus/Icarus/Database/Contexts/AlbumContext.cs
T
KD fd3ce9f96a #103: Remove WAV support (#105)
* #103: Adding checks to prevent .wav files from being uploaded:

* #103: Added method to create song and moving some code around

* #103: Fixed build issue

* tsk-103: Cleanup of temporary files

* tsk-103: Formatting changes

* tsk-103: Minor changes

* tsk-103: Fixing build issue

* tsk-103: Refactored enum

* CORE-23734: Refactoring

* tsk-103: Confirmed functionality is working

* Removed commented code

* Removed commented code
2025-02-16 17:24:50 -05:00

34 lines
880 B
C#

using Microsoft.EntityFrameworkCore;
using Icarus.Models;
namespace Icarus.Database.Contexts;
public class AlbumContext : DbContext
{
public DbSet<Album>? Albums { get; set; }
public AlbumContext(DbContextOptions<AlbumContext> options) : base(options) { }
public AlbumContext(string connString) : base(new DbContextOptionsBuilder<AlbumContext>()
.UseMySQL(connString).Options)
{
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<Album>()
.ToTable("Album");
}
public Album RetrieveRecord(Album album)
{
var albm = Albums!.FirstOrDefault(alb => alb.Id == album.Id);
return albm!;
}
public bool DoesRecordExist(Album album)
{
return Albums!.FirstOrDefault(alb => alb.Id == album.Id) != null ? true : false;
}
}