diff --git a/Controllers/Managers/AlbumManager.cs b/Controllers/Managers/AlbumManager.cs index 977a82d..66c5a68 100644 --- a/Controllers/Managers/AlbumManager.cs +++ b/Controllers/Managers/AlbumManager.cs @@ -1,11 +1,3 @@ -using System; -using System.Collections.Generic; -using System.Configuration; -using System.Linq; - -using Microsoft.Extensions.Configuration; - -using Icarus.Controllers.Utilities; using Icarus.Models; using Icarus.Database.Contexts; diff --git a/Controllers/Managers/ArtistManager.cs b/Controllers/Managers/ArtistManager.cs index b2141d3..31b4f83 100644 --- a/Controllers/Managers/ArtistManager.cs +++ b/Controllers/Managers/ArtistManager.cs @@ -1,11 +1,3 @@ -using System; -using System.Collections.Generic; -using System.Configuration; -using System.Linq; - -using Microsoft.Extensions.Configuration; - -using Icarus.Controllers.Utilities; using Icarus.Models; using Icarus.Database.Contexts; diff --git a/Controllers/Managers/CoverArtManager.cs b/Controllers/Managers/CoverArtManager.cs index 33e093d..4026d21 100644 --- a/Controllers/Managers/CoverArtManager.cs +++ b/Controllers/Managers/CoverArtManager.cs @@ -1,11 +1,3 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.IO; - -using Microsoft.AspNetCore.Http; -using Microsoft.Extensions.Configuration; - using Icarus.Constants; using Icarus.Controllers.Utilities; using Icarus.Database.Contexts; diff --git a/Controllers/Managers/DirectoryManager.cs b/Controllers/Managers/DirectoryManager.cs index 07f905f..d8d05ff 100644 --- a/Controllers/Managers/DirectoryManager.cs +++ b/Controllers/Managers/DirectoryManager.cs @@ -1,9 +1,3 @@ -using System; -using System.IO; -using System.Linq; - -using Microsoft.Extensions.Configuration; - using Icarus.Models; using Icarus.Types; diff --git a/Controllers/Managers/GenreManager.cs b/Controllers/Managers/GenreManager.cs index c05576b..009f76b 100644 --- a/Controllers/Managers/GenreManager.cs +++ b/Controllers/Managers/GenreManager.cs @@ -1,11 +1,3 @@ -using System; -using System.Collections.Generic; -using System.Configuration; -using System.Linq; - -using Microsoft.Extensions.Configuration; - -using Icarus.Controllers.Utilities; using Icarus.Models; using Icarus.Database.Contexts; diff --git a/Controllers/Managers/SongManager.cs b/Controllers/Managers/SongManager.cs index 3fb3f52..7e4a93c 100644 --- a/Controllers/Managers/SongManager.cs +++ b/Controllers/Managers/SongManager.cs @@ -1,14 +1,3 @@ -using System; -using System.Collections.Generic; -using System.Configuration; -using System.Linq; -using System.Data; -using System.IO; -using System.Threading.Tasks; - -using Microsoft.AspNetCore.Http; -using Microsoft.Extensions.Configuration; - using NLog; using Icarus.Controllers.Utilities; diff --git a/Controllers/Managers/TokenManager.cs b/Controllers/Managers/TokenManager.cs index ece55fc..de2a185 100644 --- a/Controllers/Managers/TokenManager.cs +++ b/Controllers/Managers/TokenManager.cs @@ -1,12 +1,7 @@ -using System; -using System.Collections.Generic; -using System.Linq; using System.Security.Claims; -using System.Threading.Tasks; using System.IdentityModel.Tokens.Jwt; using System.Text; -using Microsoft.Extensions.Configuration; using Microsoft.IdentityModel.Tokens; using Newtonsoft.Json; using RestSharp; diff --git a/Controllers/v1/CoverArtController.cs b/Controllers/v1/CoverArtController.cs index a973bb6..97fbbf1 100644 --- a/Controllers/v1/CoverArtController.cs +++ b/Controllers/v1/CoverArtController.cs @@ -1,11 +1,5 @@ -using System; -using System.Linq; -using System.Threading.Tasks; - using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.Logging; using Icarus.Controllers.Managers; using Icarus.Database.Contexts; @@ -78,5 +72,20 @@ public class CoverArtController : BaseController return NotFound(); } } + + [HttpGet("data/download/{id}")] + public async Task Download(int id) + { + var songContext = new SongContext(_connectionString); + var covMgr = new CoverArtManager(this._config); + + var songMetaData = songContext.RetrieveRecord(new Song { SongID = id}); + var filename = songMetaData.Title + Constants.FileExtensions.JPG_EXTENSION; + var c = covMgr.GetCoverArt(songMetaData); + + var data = await c.GetData(); + + return File(data, "application/x-msdownload", filename); + } #endregion } diff --git a/Controllers/v1/SongCompressedDataControllers.cs b/Controllers/v1/SongCompressedDataControllers.cs index 8a3c0c2..5d67644 100644 --- a/Controllers/v1/SongCompressedDataControllers.cs +++ b/Controllers/v1/SongCompressedDataControllers.cs @@ -1,16 +1,6 @@ -using System; -using System.Collections.Generic; -using System.Configuration; -using System.IO; -using System.Linq; -using System.Threading.Tasks; - using Microsoft.AspNetCore.Authorization; -using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; -using Microsoft.Extensions.Configuration; -using Icarus.Controllers.Managers; using Icarus.Controllers.Utilities; using Icarus.Models; using Icarus.Database.Contexts; diff --git a/Controllers/v1/SongDataController.cs b/Controllers/v1/SongDataController.cs index 9f52aa4..53f4fcf 100644 --- a/Controllers/v1/SongDataController.cs +++ b/Controllers/v1/SongDataController.cs @@ -1,16 +1,5 @@ -using System; -using System.Collections.Generic; -using System.Configuration; -using System.IO; -using System.Linq; -using System.Threading.Tasks; - -using Microsoft.AspNetCore.Authorization; -using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.Logging; -using Newtonsoft.Json; using Icarus.Controllers.Managers; using Icarus.Models; diff --git a/Models/BaseResult.cs b/Models/BaseResult.cs index c9c236c..e86e495 100644 --- a/Models/BaseResult.cs +++ b/Models/BaseResult.cs @@ -1,5 +1,3 @@ -using System; - using Newtonsoft.Json; namespace Icarus.Models; diff --git a/Models/CoverArt.cs b/Models/CoverArt.cs index 7b22816..370c252 100644 --- a/Models/CoverArt.cs +++ b/Models/CoverArt.cs @@ -1,10 +1,3 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations.Schema; -using System.Linq; -using System.Reflection.Metadata; -using System.Text; - using Newtonsoft.Json; namespace Icarus.Models; @@ -33,5 +26,7 @@ public class CoverArt return (flag == 0) ? filename : $"{filename}{extension}"; } + + public async Task GetData() => await File.ReadAllBytesAsync(this.ImagePath); #endregion } diff --git a/Models/LoginResult.cs b/Models/LoginResult.cs index 4553bbd..d3183d6 100644 --- a/Models/LoginResult.cs +++ b/Models/LoginResult.cs @@ -1,5 +1,3 @@ -using System; - using Newtonsoft.Json; namespace Icarus.Models; diff --git a/Models/RegisterResult.cs b/Models/RegisterResult.cs index 6d0cdcb..96ec1ce 100644 --- a/Models/RegisterResult.cs +++ b/Models/RegisterResult.cs @@ -1,5 +1,3 @@ -using System; - using Newtonsoft.Json; namespace Icarus.Models; diff --git a/Models/Song.cs b/Models/Song.cs index 53c58b9..b295983 100644 --- a/Models/Song.cs +++ b/Models/Song.cs @@ -1,7 +1,4 @@ -using System; using System.ComponentModel.DataAnnotations.Schema; -using System.Linq; -using System.Threading.Tasks; using Newtonsoft.Json; diff --git a/Models/SongData.cs b/Models/SongData.cs index d710ff0..ad03c59 100644 --- a/Models/SongData.cs +++ b/Models/SongData.cs @@ -1,6 +1,3 @@ -using System; -using System.Text; - namespace Icarus.Models; public class SongData diff --git a/Models/SongResult.cs b/Models/SongResult.cs index 2ae0f02..266090c 100644 --- a/Models/SongResult.cs +++ b/Models/SongResult.cs @@ -1,5 +1,3 @@ -using System; - using Newtonsoft.Json; namespace Icarus.Models; diff --git a/Models/User.cs b/Models/User.cs index d3b8759..f69727e 100644 --- a/Models/User.cs +++ b/Models/User.cs @@ -1,7 +1,5 @@ -using System; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; -using System.Linq; using Newtonsoft.Json;