tsk-76: Added model and context for AccessLevel #108

Merged
kdeng00 merged 14 commits from tsk-76 into master 2025-03-11 21:45:32 -04:00
2 changed files with 36 additions and 8 deletions
Showing only changes of commit 4a4c021c4f - Show all commits
+18 -8
View File
@@ -165,7 +165,7 @@ public class SongManager : BaseManager
} }
} }
public Song SaveFlacSongToFileSystem(IFormFile songFile, IFormFile coverArtData, Song song) public Song SaveFlacSongToFileSystem(IFormFile songFile, IFormFile coverArtData, Song song)
{ {
// Save temp song (Should already be saved to the filesystem by the time it gets to this method) // Save temp song (Should already be saved to the filesystem by the time it gets to this method)
@@ -345,10 +345,10 @@ public class SongManager : BaseManager
{ {
_logger.Info("Starting process to save the song to the database"); _logger.Info("Starting process to save the song to the database");
var albumMgr = new AlbumManager(_config!); var albumMgr = new AlbumManager(this._config!);
var artistMgr = new ArtistManager(_config!); var artistMgr = new ArtistManager(this._config!);
var genreMgr = new GenreManager(_config!); var genreMgr = new GenreManager(this._config!);
var coverMgr = new CoverArtManager(_config!); var coverMgr = new CoverArtManager(this._config!);
albumMgr.SaveAlbumToDatabase(ref song); albumMgr.SaveAlbumToDatabase(ref song);
artistMgr.SaveArtistToDatabase(ref song); artistMgr.SaveArtistToDatabase(ref song);
genreMgr.SaveGenreToDatabase(ref song); genreMgr.SaveGenreToDatabase(ref song);
@@ -356,10 +356,20 @@ public class SongManager : BaseManager
var info = "Saving Song to DB"; var info = "Saving Song to DB";
_logger.Info(info); _logger.Info(info);
_songContext!.Add(song); this._songContext!.Add(song);
_songContext!.SaveChanges(); this._songContext!.SaveChanges();
coverMgr.SaveCoverArtToDatabase(ref song, ref cover!); 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();
} }
+18
View File
@@ -12,4 +12,22 @@ public class AccessLevel
[Newtonsoft.Json.JsonProperty("song_id")] [Newtonsoft.Json.JsonProperty("song_id")]
public int SongId { get; set; } public int SongId { get; set; }
#endregion #endregion
#region Methods
public static AccessLevel DefaultLevel()
{
return new AccessLevel
{
Level = "Public"
};
}
public static AccessLevel PrivateLevel()
{
return new AccessLevel
{
Level = "Private"
};
}
#endregion
} }