562bc87822
* #74: Add UserID to the Song model * #74: Added functionality to retrieve user id from the token * #74: Songs will now contain the User Id when uploading * Updated Readme and script to add migrations * #74: Some cleanup
35 lines
924 B
C#
35 lines
924 B
C#
using Microsoft.EntityFrameworkCore;
|
|
|
|
using Icarus.Models;
|
|
|
|
namespace Icarus.Database.Contexts;
|
|
|
|
public class ArtistContext : DbContext
|
|
{
|
|
public DbSet<Artist> Artists { get; set; }
|
|
|
|
public ArtistContext(DbContextOptions<ArtistContext> options) : base (options) { }
|
|
public ArtistContext(string connString) : base(new DbContextOptionsBuilder<ArtistContext>()
|
|
.UseMySQL(connString).Options)
|
|
{
|
|
}
|
|
|
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
|
{
|
|
modelBuilder.Entity<Artist>()
|
|
.ToTable("Artist");
|
|
}
|
|
|
|
public Artist RetrieveRecord(Artist artist)
|
|
{
|
|
|
|
return Artists.FirstOrDefault(arst => arst.ArtistID == artist.ArtistID);
|
|
}
|
|
|
|
|
|
public bool DoesRecordExist(Artist artist)
|
|
{
|
|
return Artists.FirstOrDefault(arst => arst.ArtistID == artist.ArtistID) != null ? true : false;
|
|
}
|
|
}
|