Saving changes
This commit is contained in:
@@ -149,7 +149,7 @@ public class TokenManager : BaseManager
|
||||
return null;
|
||||
}
|
||||
|
||||
public int? RetrieveUserIdFromToken(string token)
|
||||
public Guid? RetrieveUserIdFromToken(string token)
|
||||
{
|
||||
var parsedToken = this.ContainsBearer(token) ? this.StripBearer(token) : token;
|
||||
var tokenHandler = new JwtSecurityTokenHandler();
|
||||
@@ -159,7 +159,15 @@ public class TokenManager : BaseManager
|
||||
{
|
||||
if (item.Key == "user_id")
|
||||
{
|
||||
return Convert.ToInt32(item.Value);
|
||||
if (item.Value != null)
|
||||
{
|
||||
var id = item.Value.ToString();
|
||||
return Guid.Parse(id!);
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -27,9 +27,9 @@ public class AccessLevelController : BaseController
|
||||
|
||||
#region HTTP Routes
|
||||
[HttpGet]
|
||||
public IActionResult GetAccessLevels(int? id, int? songId)
|
||||
public IActionResult GetAccessLevels(Guid? id, Guid? songId)
|
||||
{
|
||||
var accLevel = new Models.AccessLevel { Id = 0 };
|
||||
var accLevel = new Models.AccessLevel { };
|
||||
var accessLevelContext = new Database.Contexts.AccessLevelContext(_connectionString!);
|
||||
|
||||
if (id != null)
|
||||
@@ -43,7 +43,7 @@ public class AccessLevelController : BaseController
|
||||
|
||||
var response = new GetAccessLevelsResponse { Data = new List<Models.AccessLevel>() };
|
||||
|
||||
if (accLevel?.Id > 0)
|
||||
if (accLevel?.Id.ToString().Length > 0)
|
||||
{
|
||||
response.Subject = "Successful";
|
||||
response.Data.Add(accLevel);
|
||||
@@ -57,7 +57,7 @@ public class AccessLevelController : BaseController
|
||||
}
|
||||
|
||||
[HttpPatch("{id}")]
|
||||
public IActionResult UpdateAccessLevel(int id, [FromBody] Models.AccessLevel accessLevel)
|
||||
public IActionResult UpdateAccessLevel(Guid id, [FromBody] Models.AccessLevel accessLevel)
|
||||
{
|
||||
var response = new UpdateAccessLevelResponse { Data = new List<Models.AccessLevel>() };
|
||||
var targetLevel = accessLevel.Level;
|
||||
|
||||
@@ -46,7 +46,7 @@ public class AlbumController : BaseController
|
||||
}
|
||||
|
||||
[HttpGet("{id}")]
|
||||
public IActionResult GetAlbum(int id)
|
||||
public IActionResult GetAlbum(Guid id)
|
||||
{
|
||||
Album album = new Album { Id = id };
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ public class CoverArtController : BaseController
|
||||
}
|
||||
|
||||
[HttpGet("{id}")]
|
||||
public IActionResult GetCoverArt(int id)
|
||||
public IActionResult GetCoverArt(Guid id)
|
||||
{
|
||||
var coverArt = new CoverArt { Id = id };
|
||||
|
||||
@@ -74,7 +74,7 @@ public class CoverArtController : BaseController
|
||||
}
|
||||
|
||||
[HttpGet("data/download/{id}")]
|
||||
public async Task<IActionResult> Download(int id, [FromQuery] bool? randomizeFilename)
|
||||
public async Task<IActionResult> Download(Guid id, [FromQuery] bool? randomizeFilename)
|
||||
{
|
||||
var songContext = new SongContext(_connectionString!);
|
||||
var covMgr = new CoverArtManager(this._config!);
|
||||
|
||||
@@ -50,7 +50,7 @@ public class GenreController : BaseController
|
||||
}
|
||||
|
||||
[HttpGet("{id}")]
|
||||
public IActionResult GetGenre(int id)
|
||||
public IActionResult GetGenre(Guid id)
|
||||
{
|
||||
var genre = new Genre { Id = id };
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ public class SongCompressedDataController : BaseController
|
||||
|
||||
#region API Routes
|
||||
[HttpGet("{id}")]
|
||||
public async Task<IActionResult> DownloadCompressedSong(int id, [FromQuery] bool? randomizeFilename)
|
||||
public async Task<IActionResult> DownloadCompressedSong(Guid id, [FromQuery] bool? randomizeFilename)
|
||||
{
|
||||
var context = new SongContext(_connectionString!);
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@ public class SongController : BaseController
|
||||
}
|
||||
|
||||
[HttpGet("{id}")]
|
||||
public IActionResult GetSong(int id)
|
||||
public IActionResult GetSong(Guid id)
|
||||
{
|
||||
var context = new SongContext(_connectionString!);
|
||||
|
||||
@@ -65,14 +65,14 @@ public class SongController : BaseController
|
||||
|
||||
Console.WriteLine("Here");
|
||||
|
||||
if (song.Id != 0)
|
||||
if (song.Id.ToString().Length != 0)
|
||||
return Ok(song);
|
||||
else
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
[HttpPut("{id}")]
|
||||
public IActionResult UpdateSong(int id, [FromBody] Song song)
|
||||
public IActionResult UpdateSong(Guid id, [FromBody] Song song)
|
||||
{
|
||||
song.Id = id;
|
||||
Console.WriteLine("Retrieving filepath of song");
|
||||
|
||||
@@ -40,7 +40,7 @@ public class SongDataController : BaseController
|
||||
|
||||
|
||||
[HttpGet("download/{id}")]
|
||||
public IActionResult Download(int id, [FromQuery] bool? randomizeFilename)
|
||||
public IActionResult Download(Guid id, [FromQuery] bool? randomizeFilename)
|
||||
{
|
||||
var tokenManager = new TokenManager(this._config!);
|
||||
var songContext = new SongContext(this._connectionString!);
|
||||
@@ -172,7 +172,7 @@ public class SongDataController : BaseController
|
||||
}
|
||||
|
||||
[HttpDelete("delete/{id}")]
|
||||
public IActionResult DeleteSong(int id)
|
||||
public IActionResult DeleteSong(Guid id)
|
||||
{
|
||||
var songContext = new SongContext(_connectionString!);
|
||||
var songMetaData = songContext.RetrieveRecord(new Song { Id = id });
|
||||
|
||||
@@ -32,7 +32,7 @@ public class SongStreamController : BaseController
|
||||
|
||||
#region HTTP endpoints
|
||||
[HttpGet("{id}")]
|
||||
public async Task<IActionResult> StreamSong(int id)
|
||||
public async Task<IActionResult> StreamSong(Guid id)
|
||||
{
|
||||
var context = new SongContext(_config!.GetConnectionString("DefaultConnection")!);
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ public class AccessLevelContext : DbContext
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
public Models.AccessLevel? GetAccessLevel(int songId)
|
||||
public Models.AccessLevel? GetAccessLevel(Guid songId)
|
||||
{
|
||||
var accessLevel = this.AccessLevels!.FirstOrDefault(acc => acc.SongId == songId);
|
||||
return accessLevel;
|
||||
|
||||
@@ -11,7 +11,7 @@ public class AccessLevel
|
||||
[Newtonsoft.Json.JsonProperty("level")]
|
||||
public string? Level { get; set; }
|
||||
[Newtonsoft.Json.JsonProperty("song_id")]
|
||||
public int SongId { get; set; }
|
||||
public Guid SongId { get; set; }
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
+5
-5
@@ -41,17 +41,17 @@ public class Song
|
||||
[JsonProperty("disc_count")]
|
||||
public int DiscCount { get; set; } = 0;
|
||||
[JsonIgnore]
|
||||
public int? AlbumId { get; set; }
|
||||
public Guid? AlbumId { get; set; }
|
||||
[JsonIgnore]
|
||||
public int? ArtistId { get; set; }
|
||||
public Guid? ArtistId { get; set; }
|
||||
[JsonIgnore]
|
||||
public int? GenreId { get; set; }
|
||||
public Guid? GenreId { get; set; }
|
||||
[JsonIgnore]
|
||||
public int? CoverArtId { get; set; }
|
||||
public Guid? CoverArtId { get; set; }
|
||||
[JsonProperty("date_created")]
|
||||
public DateTime DateCreated { get; set; }
|
||||
[JsonProperty("user_id")]
|
||||
public int UserId { get; set; }
|
||||
public Guid UserId { get; set; }
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user