* #95: Updated Id of the CoverArt model * Model and migration changes
This commit was merged in pull request #99.
This commit is contained in:
@@ -45,14 +45,14 @@ public class AlbumManager : BaseManager
|
||||
_albumContext.Add(album);
|
||||
_albumContext.SaveChanges();
|
||||
|
||||
Console.WriteLine($"Album Id {album.AlbumID}");
|
||||
Console.WriteLine($"Album Id {album.Id}");
|
||||
}
|
||||
else
|
||||
{
|
||||
album.AlbumID = albumRetrieved.AlbumID;
|
||||
album.Id = albumRetrieved.Id;
|
||||
}
|
||||
|
||||
song.AlbumID = album.AlbumID;
|
||||
song.AlbumId = album.Id;
|
||||
}
|
||||
|
||||
|
||||
@@ -138,7 +138,7 @@ public class AlbumManager : BaseManager
|
||||
private int SongsInAlbum(Album album)
|
||||
{
|
||||
var sngContext = new SongContext(_connectionString);
|
||||
var songs = sngContext.Songs.Where(sng => sng.AlbumID == album.AlbumID).ToList();
|
||||
var songs = sngContext.Songs.Where(sng => sng.AlbumId == album.Id).ToList();
|
||||
|
||||
return songs.Count;
|
||||
}
|
||||
|
||||
@@ -45,10 +45,10 @@ public class ArtistManager : BaseManager
|
||||
}
|
||||
else
|
||||
{
|
||||
artist.ArtistID = artistRetrieved.ArtistID;
|
||||
artist.Id = artistRetrieved.Id;
|
||||
}
|
||||
|
||||
song.ArtistID = artist.ArtistID;
|
||||
song.ArtistId = artist.Id;
|
||||
}
|
||||
|
||||
public Artist UpdateArtistInDatabase(Song oldSongRecord, Song newSongRecord)
|
||||
@@ -120,7 +120,7 @@ public class ArtistManager : BaseManager
|
||||
private int SongsOfArtist(Artist artist)
|
||||
{
|
||||
var sngContext = new SongContext(_connectionString);
|
||||
var songs = sngContext.Songs.Where(sng => sng.ArtistID == artist.ArtistID).ToList();
|
||||
var songs = sngContext.Songs.Where(sng => sng.ArtistId == artist.Id).ToList();
|
||||
|
||||
return songs.Count;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
using System;
|
||||
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using NLog;
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@ using Icarus.Constants;
|
||||
using Icarus.Controllers.Utilities;
|
||||
using Icarus.Database.Contexts;
|
||||
using Icarus.Models;
|
||||
using Icarus.Types;
|
||||
|
||||
namespace Icarus.Controllers.Managers;
|
||||
|
||||
@@ -33,7 +32,7 @@ public class CoverArtManager : BaseManager
|
||||
_coverArtContext.Add(coverArt);
|
||||
_coverArtContext.SaveChanges();
|
||||
|
||||
song.CoverArtID = coverArt.CoverArtID;
|
||||
song.CoverArtId = coverArt.Id;
|
||||
}
|
||||
public void DeleteCoverArtFromDatabase(CoverArt coverArt)
|
||||
{
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
using System.Reflection.PortableExecutable;
|
||||
using Icarus.Models;
|
||||
using Icarus.Types;
|
||||
|
||||
|
||||
@@ -45,10 +45,10 @@ public class GenreManager : BaseManager
|
||||
}
|
||||
else
|
||||
{
|
||||
genre.GenreID = genreRetrieved.GenreID;
|
||||
genre.Id = genreRetrieved.Id;
|
||||
}
|
||||
|
||||
song.GenreID = genre.GenreID;
|
||||
song.GenreId = genre.Id;
|
||||
}
|
||||
|
||||
public Genre UpdateGenreInDatabase(Song oldSongRecord, Song newSongRecord)
|
||||
@@ -120,7 +120,7 @@ public class GenreManager : BaseManager
|
||||
private int SongsInGenre(Genre genre)
|
||||
{
|
||||
var sngContext = new SongContext(_connectionString);
|
||||
var songs = sngContext.Songs.Where(sng => sng.GenreID == genre.GenreID).ToList();
|
||||
var songs = sngContext.Songs.Where(sng => sng.GenreId == genre.Id).ToList();
|
||||
|
||||
return songs.Count;
|
||||
}
|
||||
|
||||
@@ -77,13 +77,13 @@ public class SongManager : BaseManager
|
||||
var gnrMgr = new GenreManager(_config);
|
||||
var artMgr = new ArtistManager(_config);
|
||||
var updatedAlbum = albMgr.UpdateAlbumInDatabase(oldSongRecord, updatedSong);
|
||||
oldSongRecord.AlbumID = updatedAlbum.AlbumID;
|
||||
oldSongRecord.AlbumId = updatedAlbum.Id;
|
||||
|
||||
var updatedArtist = artMgr.UpdateArtistInDatabase(oldSongRecord, updatedSong);
|
||||
oldSongRecord.ArtistID = updatedArtist.ArtistID;
|
||||
oldSongRecord.ArtistId = updatedArtist.Id;
|
||||
|
||||
var updatedGenre = gnrMgr.UpdateGenreInDatabase(oldSongRecord, updatedSong);
|
||||
oldSongRecord.GenreID = updatedGenre.GenreID;
|
||||
oldSongRecord.GenreId = updatedGenre.Id;
|
||||
|
||||
UpdateSongInDatabase(ref oldSongRecord, ref updatedSong, ref result);
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ public class TokenManager : BaseManager
|
||||
private string _audience;
|
||||
private string _grantType;
|
||||
private string _url;
|
||||
private string SUCCESSFUL_TOKEN_MESSAGE = "Successfully retrieved token";
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -67,12 +68,7 @@ public class TokenManager : BaseManager
|
||||
.DeserializeObject<TokenTierOne>(response.Content);
|
||||
_logger.Info("Response deserialized");
|
||||
|
||||
return new LoginResult
|
||||
{
|
||||
UserID = user.UserID, Username = user.Username, Token = tokenResult.AccessToken,
|
||||
TokenType = tokenResult.TokenType, Expiration = tokenResult.Expiration,
|
||||
Message = "Successfully retrieved token"
|
||||
};
|
||||
return this.InitializeLoginResult(user, tokenResult);
|
||||
}
|
||||
|
||||
|
||||
@@ -81,7 +77,7 @@ public class TokenManager : BaseManager
|
||||
var tokenResult = new TokenTierOne{ TokenType = "JWT" };
|
||||
|
||||
var payload = Payload();
|
||||
payload.Add(new Claim("user_id", user.UserID.ToString(), ClaimValueTypes.Integer));
|
||||
payload.Add(new Claim("user_id", user.Id.ToString(), ClaimValueTypes.Integer));
|
||||
|
||||
var tokenHandler = new JwtSecurityTokenHandler();
|
||||
var key = Encoding.ASCII.GetBytes(_config["JWT:Secret"]);
|
||||
@@ -89,7 +85,7 @@ public class TokenManager : BaseManager
|
||||
{
|
||||
Subject = new ClaimsIdentity(new Claim[]
|
||||
{
|
||||
new Claim("user_id", user.UserID.ToString(), ClaimValueTypes.Integer)
|
||||
new Claim("user_id", user.Id.ToString(), ClaimValueTypes.Integer)
|
||||
// Add more claims as needed
|
||||
}),
|
||||
Expires = DateTime.UtcNow.AddHours(1),
|
||||
@@ -109,11 +105,16 @@ public class TokenManager : BaseManager
|
||||
var exp = Math.Floor((expiredDate - DateTime.UnixEpoch).TotalSeconds);
|
||||
tokenResult.Expiration = Convert.ToInt32(exp);
|
||||
|
||||
return this.InitializeLoginResult(user, tokenResult);
|
||||
}
|
||||
|
||||
private LoginResult InitializeLoginResult(User user, TokenTierOne token)
|
||||
{
|
||||
return new LoginResult
|
||||
{
|
||||
UserID = user.UserID, Username = user.Username, Token = tokenResult.AccessToken,
|
||||
TokenType = tokenResult.TokenType, Expiration = tokenResult.Expiration,
|
||||
Message = "Successfully retrieved token"
|
||||
UserId = user.Id, Username = user.Username, Token = token.AccessToken,
|
||||
TokenType = token.TokenType, Expiration = token.Expiration,
|
||||
Message = SUCCESSFUL_TOKEN_MESSAGE
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user