tsk-#76: Saving AccessLevel when uploading song
This commit is contained in:
@@ -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();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user