tsk-#76: Saving AccessLevel when uploading song

This commit is contained in:
phoenix
2025-03-07 22:41:31 -05:00
parent 8054fd4d1e
commit 4a4c021c4f
2 changed files with 36 additions and 8 deletions
+16 -6
View File
@@ -345,10 +345,10 @@ public class SongManager : BaseManager
{
_logger.Info("Starting process to save the song to the database");
var albumMgr = new AlbumManager(_config!);
var artistMgr = new ArtistManager(_config!);
var genreMgr = new GenreManager(_config!);
var coverMgr = new CoverArtManager(_config!);
var albumMgr = new AlbumManager(this._config!);
var artistMgr = new ArtistManager(this._config!);
var genreMgr = new GenreManager(this._config!);
var coverMgr = new CoverArtManager(this._config!);
albumMgr.SaveAlbumToDatabase(ref song);
artistMgr.SaveArtistToDatabase(ref song);
genreMgr.SaveGenreToDatabase(ref song);
@@ -356,12 +356,22 @@ public class SongManager : BaseManager
var info = "Saving Song to DB";
_logger.Info(info);
_songContext!.Add(song);
_songContext!.SaveChanges();
this._songContext!.Add(song);
this._songContext!.SaveChanges();
if (cover != null)
{
coverMgr.SaveCoverArtToDatabase(ref song, ref cover!);
}
var accessLevel = Icarus.Models.AccessLevel.DefaultLevel();
accessLevel.SongId = song.Id;
var accessLevelContext = new AccessLevelContext(this._connectionString!);
accessLevelContext.Add(accessLevel);
accessLevelContext.SaveChanges();
}
private bool DeleteSongFromFilesystem(Song song, bool deleteDirectory = false)
{
+18
View File
@@ -12,4 +12,22 @@ public class AccessLevel
[Newtonsoft.Json.JsonProperty("song_id")]
public int SongId { get; set; }
#endregion
#region Methods
public static AccessLevel DefaultLevel()
{
return new AccessLevel
{
Level = "Public"
};
}
public static AccessLevel PrivateLevel()
{
return new AccessLevel
{
Level = "Private"
};
}
#endregion
}