Functional
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.Linq;
|
||||
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
@@ -19,6 +20,8 @@ namespace Icarus.Controllers.V1
|
||||
{
|
||||
#region Fields
|
||||
private readonly ILogger<AlbumController> _logger;
|
||||
private string _connectionString;
|
||||
private IConfiguration _config;
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -27,9 +30,11 @@ namespace Icarus.Controllers.V1
|
||||
|
||||
|
||||
#region Constructors
|
||||
public AlbumController(ILogger<AlbumController> logger)
|
||||
public AlbumController(ILogger<AlbumController> logger, IConfiguration config)
|
||||
{
|
||||
_logger = logger;
|
||||
_config = config;
|
||||
_connectionString = _config.GetConnectionString("DefaultConnection");
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -41,10 +46,9 @@ namespace Icarus.Controllers.V1
|
||||
{
|
||||
List<Album> albums = new List<Album>();
|
||||
|
||||
AlbumRepository albumStoreContext = HttpContext.RequestServices
|
||||
.GetService(typeof(AlbumRepository)) as AlbumRepository;
|
||||
var albumContext = new AlbumContext(_connectionString);
|
||||
|
||||
albums = albumStoreContext.GetAlbums();
|
||||
albums = albumContext.Albums.ToList();
|
||||
|
||||
if (albums.Count > 0)
|
||||
return Ok(albums);
|
||||
@@ -58,15 +62,14 @@ namespace Icarus.Controllers.V1
|
||||
{
|
||||
Album album = new Album
|
||||
{
|
||||
AlbumId = id
|
||||
AlbumID = id
|
||||
};
|
||||
|
||||
AlbumRepository albumStoreContext = HttpContext.RequestServices
|
||||
.GetService(typeof(AlbumRepository)) as AlbumRepository;
|
||||
var albumContext = new AlbumContext(_connectionString);
|
||||
|
||||
if (albumStoreContext.DoesAlbumExist(album))
|
||||
if (albumContext.DoesRecordExist(album))
|
||||
{
|
||||
album = albumStoreContext.GetAlbum(album);
|
||||
album = albumContext.RetrieveRecord(album);
|
||||
|
||||
return Ok(album);
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
using Icarus.Models;
|
||||
using Icarus.Database.Repositories;
|
||||
using Icarus.Database.Contexts;
|
||||
|
||||
namespace Icarus.Controllers.V1
|
||||
{
|
||||
@@ -19,6 +19,8 @@ namespace Icarus.Controllers.V1
|
||||
{
|
||||
#region Fields
|
||||
private readonly ILogger<ArtistController> _logger;
|
||||
private string _connectionString;
|
||||
private IConfiguration _config;
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -27,9 +29,11 @@ namespace Icarus.Controllers.V1
|
||||
|
||||
|
||||
#region Constructors
|
||||
public ArtistController(ILogger<ArtistController> logger)
|
||||
public ArtistController(ILogger<ArtistController> logger, IConfiguration config)
|
||||
{
|
||||
_logger = logger;
|
||||
_config = config;
|
||||
_connectionString = _config.GetConnectionString("DefaultConnection");
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -39,10 +43,9 @@ namespace Icarus.Controllers.V1
|
||||
[Authorize("read:artists")]
|
||||
public IActionResult Get()
|
||||
{
|
||||
ArtistRepository artistStoreContext = HttpContext.RequestServices
|
||||
.GetService(typeof(ArtistRepository)) as ArtistRepository;
|
||||
var artistContext = new ArtistContext(_connectionString);
|
||||
|
||||
var artists = artistStoreContext.GetArtists();
|
||||
var artists = artistContext.Artists.ToList();
|
||||
|
||||
if (artists.Count > 0)
|
||||
return Ok(artists);
|
||||
@@ -56,15 +59,14 @@ namespace Icarus.Controllers.V1
|
||||
{
|
||||
Artist artist = new Artist
|
||||
{
|
||||
ArtistId = id
|
||||
ArtistID = id
|
||||
};
|
||||
|
||||
ArtistRepository artistStoreContext = HttpContext.RequestServices
|
||||
.GetService(typeof(ArtistRepository)) as ArtistRepository;
|
||||
var artistContext = new ArtistContext(_connectionString);
|
||||
|
||||
if (artistStoreContext.DoesArtistExist(artist))
|
||||
if (artistContext.DoesRecordExist(artist))
|
||||
{
|
||||
artist = artistStoreContext.GetArtist(artist);
|
||||
artist = artistContext.RetrieveRecord(artist);
|
||||
|
||||
return Ok(artist);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
@@ -9,7 +10,7 @@ using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
using Icarus.Controllers.Managers;
|
||||
using Icarus.Database.Repositories;
|
||||
using Icarus.Database.Contexts;
|
||||
using Icarus.Models;
|
||||
|
||||
namespace Icarus.Controllers.V1
|
||||
@@ -20,26 +21,27 @@ namespace Icarus.Controllers.V1
|
||||
{
|
||||
#region Fields
|
||||
private readonly ILogger<CoverArtController> _logger;
|
||||
private string _connectionString;
|
||||
private IConfiguration _config;
|
||||
#endregion
|
||||
|
||||
|
||||
#region Constructors
|
||||
public CoverArtController(ILogger<CoverArtController> logger)
|
||||
public CoverArtController(ILogger<CoverArtController> logger, IConfiguration config)
|
||||
{
|
||||
_logger = logger;
|
||||
_config = config;
|
||||
_connectionString = _config.GetConnectionString("DefaultConnection");
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
#region HTTP Routes
|
||||
public async Task<IActionResult> Get()
|
||||
public IActionResult Get()
|
||||
{
|
||||
var coverArtRepository = HttpContext
|
||||
.RequestServices
|
||||
.GetService(
|
||||
typeof(CoverArtRepository)) as CoverArtRepository;
|
||||
var coverArtContext = new CoverArtContext(_connectionString);
|
||||
|
||||
var coverArtRecords = coverArtRepository.GetCoverArtRecords();
|
||||
var coverArtRecords = coverArtContext.CoverArtImages.ToList();
|
||||
|
||||
if (coverArtRecords == null)
|
||||
{
|
||||
@@ -51,26 +53,22 @@ namespace Icarus.Controllers.V1
|
||||
_logger.LogInformation("Found cover art records");
|
||||
return Ok(coverArtRecords);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
[HttpGet("{id}")]
|
||||
[Authorize("download:cover_art")]
|
||||
public async Task<IActionResult> Get(int id)
|
||||
{
|
||||
var coverArt = new CoverArt { CoverArtId = id };
|
||||
var coverArt = new CoverArt { CoverArtID = id };
|
||||
|
||||
var coverArtRepository = HttpContext
|
||||
.RequestServices
|
||||
.GetService(
|
||||
typeof(CoverArtRepository)) as CoverArtRepository;
|
||||
var coverArtContext = new CoverArtContext(_connectionString);
|
||||
|
||||
coverArt = coverArtRepository.GetCoverArt(coverArt);
|
||||
coverArt = coverArtContext.RetrieveRecord(coverArt);
|
||||
|
||||
if (coverArt != null)
|
||||
{
|
||||
_logger.LogInformation("Found cover art record");
|
||||
var coverArtBytes = System.IO.File.ReadAllBytes(
|
||||
var coverArtBytes = await System.IO.File.ReadAllBytesAsync(
|
||||
coverArt.ImagePath);
|
||||
|
||||
return File(coverArtBytes, "application/x-msdownload",
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
@@ -7,7 +8,7 @@ using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
using Icarus.Models;
|
||||
using Icarus.Database.Repositories;
|
||||
using Icarus.Database.Contexts;
|
||||
|
||||
namespace Icarus.Controllers.V1
|
||||
{
|
||||
@@ -17,6 +18,8 @@ namespace Icarus.Controllers.V1
|
||||
{
|
||||
#region Fields
|
||||
private readonly ILogger<GenreController> _logger;
|
||||
private string _connectionString;
|
||||
private IConfiguration _config;
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -25,9 +28,11 @@ namespace Icarus.Controllers.V1
|
||||
|
||||
|
||||
#region Constructors
|
||||
public GenreController(ILogger<GenreController> logger)
|
||||
public GenreController(ILogger<GenreController> logger, IConfiguration config)
|
||||
{
|
||||
_logger = logger;
|
||||
_config = config;
|
||||
_connectionString = _config.GetConnectionString("DefaultConnection");
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -39,10 +44,9 @@ namespace Icarus.Controllers.V1
|
||||
{
|
||||
var genres = new List<Genre>();
|
||||
|
||||
var genreStore = HttpContext.RequestServices
|
||||
.GetService(typeof(GenreRepository)) as GenreRepository;
|
||||
var genreStore = new GenreContext(_connectionString);
|
||||
|
||||
genres = genreStore.GetGenres();
|
||||
genres = genreStore.Genres.ToList();
|
||||
|
||||
if (genres.Count > 0)
|
||||
return Ok(genres);
|
||||
@@ -56,15 +60,14 @@ namespace Icarus.Controllers.V1
|
||||
{
|
||||
var genre = new Genre
|
||||
{
|
||||
GenreId = id
|
||||
GenreID = id
|
||||
};
|
||||
|
||||
var genreStore = HttpContext.RequestServices
|
||||
.GetService(typeof(GenreRepository)) as GenreRepository;
|
||||
var genreStore = new GenreContext(_connectionString);
|
||||
|
||||
if (genreStore.DoesGenreExist(genre))
|
||||
if (genreStore.DoesRecordExist(genre))
|
||||
{
|
||||
genre = genreStore.GetGenre(genre);
|
||||
genre = genreStore.RetrieveRecord(genre);
|
||||
|
||||
return Ok(genre);
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ using Microsoft.Extensions.Logging;
|
||||
using Icarus.Controllers.Managers;
|
||||
using Icarus.Controllers.Utilities;
|
||||
using Icarus.Models;
|
||||
using Icarus.Database.Repositories;
|
||||
using Icarus.Database.Contexts;
|
||||
|
||||
namespace Icarus.Controllers.V1
|
||||
{
|
||||
@@ -20,6 +20,7 @@ namespace Icarus.Controllers.V1
|
||||
public class LoginController : ControllerBase
|
||||
{
|
||||
#region Fields
|
||||
private string _connectionString;
|
||||
private IConfiguration _config;
|
||||
private ILogger<LoginController> _logger;
|
||||
#endregion
|
||||
@@ -32,8 +33,9 @@ namespace Icarus.Controllers.V1
|
||||
#region Contructors
|
||||
public LoginController(IConfiguration config, ILogger<LoginController> logger)
|
||||
{
|
||||
_config = config;
|
||||
_logger = logger;
|
||||
_config = config;
|
||||
_connectionString = _config.GetConnectionString("DefaultConnection");
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -41,8 +43,7 @@ namespace Icarus.Controllers.V1
|
||||
#region HTTP endpoints
|
||||
public IActionResult Post([FromBody] User user)
|
||||
{
|
||||
UserRepository context = HttpContext.RequestServices
|
||||
.GetService(typeof(UserRepository)) as UserRepository;
|
||||
var context = new UserContext(_connectionString);
|
||||
|
||||
_logger.LogInformation("Starting process of validating credentials");
|
||||
|
||||
@@ -54,9 +55,9 @@ namespace Icarus.Controllers.V1
|
||||
Username = user.Username
|
||||
};
|
||||
|
||||
if (context.DoesUserExist(user))
|
||||
if (context.Users.FirstOrDefault(usr => usr.Username.Equals(user.Username)) != null)
|
||||
{
|
||||
user = context.RetrieveUser(user);
|
||||
user = context.Users.FirstOrDefault(usr => usr.Username.Equals(user.Username));
|
||||
|
||||
var validatePass = new PasswordEncryption();
|
||||
var validated = validatePass.VerifyPassword(user, password);
|
||||
|
||||
@@ -19,6 +19,7 @@ namespace Icarus.Controllers.V1
|
||||
public class RegisterController : ControllerBase
|
||||
{
|
||||
#region Fields
|
||||
private string _connectionString;
|
||||
private IConfiguration _config;
|
||||
#endregion
|
||||
|
||||
@@ -31,6 +32,7 @@ namespace Icarus.Controllers.V1
|
||||
public RegisterController(IConfiguration config)
|
||||
{
|
||||
_config = config;
|
||||
_connectionString = _config.GetConnectionString("DefaultConnection");
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -40,11 +42,14 @@ namespace Icarus.Controllers.V1
|
||||
PasswordEncryption pe = new PasswordEncryption();
|
||||
user.Password = pe.HashPassword(user);
|
||||
user.EmailVerified = false;
|
||||
user.Status = "Registered";
|
||||
user.DateCreated = DateTime.Now;
|
||||
|
||||
var context = new UserContext(_config.GetConnectionString("DefaultConnection"));
|
||||
UserContext context = null;
|
||||
|
||||
try
|
||||
{
|
||||
context = new UserContext(_config.GetConnectionString("DefaultConnection"));
|
||||
context.Add(user);
|
||||
context.SaveChanges();
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ using Microsoft.Extensions.Configuration;
|
||||
using Icarus.Controllers.Managers;
|
||||
using Icarus.Controllers.Utilities;
|
||||
using Icarus.Models;
|
||||
using Icarus.Database.Repositories;
|
||||
using Icarus.Database.Contexts;
|
||||
|
||||
namespace Icarus.Controllers.V1
|
||||
{
|
||||
@@ -22,6 +22,7 @@ namespace Icarus.Controllers.V1
|
||||
public class SongCompressedDataController : ControllerBase
|
||||
{
|
||||
#region Fields
|
||||
private string _connectionString;
|
||||
private IConfiguration _config;
|
||||
private string _songTempDir;
|
||||
private string _archiveDir;
|
||||
@@ -35,9 +36,10 @@ namespace Icarus.Controllers.V1
|
||||
#region Constructor
|
||||
public SongCompressedDataController(IConfiguration config)
|
||||
{
|
||||
_config = config;
|
||||
_songTempDir = _config.GetValue<string>("TemporaryMusicPath");
|
||||
_archiveDir = _config.GetValue<string>("ArchivePath");
|
||||
_config = config;
|
||||
_connectionString = _config.GetConnectionString("DefaultConnection");
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -47,15 +49,14 @@ namespace Icarus.Controllers.V1
|
||||
[Authorize("download:songs")]
|
||||
public async Task<IActionResult> Get(int id)
|
||||
{
|
||||
SongRepository context = HttpContext.RequestServices
|
||||
.GetService(typeof(SongRepository)) as SongRepository;
|
||||
var context = new SongContext(_connectionString);
|
||||
|
||||
SongCompression cmp = new SongCompression(_archiveDir);
|
||||
|
||||
Console.WriteLine($"Archive directory root: {_archiveDir}");
|
||||
|
||||
Console.WriteLine("Starting process of retrieving comrpessed song");
|
||||
SongData song = await cmp.RetrieveCompressedSong(context.GetSong(id));
|
||||
SongData song = await cmp.RetrieveCompressedSong(context.RetrieveRecord(new Song{ SongID = id }));
|
||||
|
||||
return File(song.Data, "application/x-msdownload", cmp.CompressedSongFilename);
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ using Microsoft.Extensions.Logging;
|
||||
using Icarus.Controllers.Managers;
|
||||
using Icarus.Controllers.Utilities;
|
||||
using Icarus.Models;
|
||||
using Icarus.Database.Repositories;
|
||||
using Icarus.Database.Contexts;
|
||||
|
||||
namespace Icarus.Controllers.V1
|
||||
{
|
||||
@@ -22,6 +22,7 @@ namespace Icarus.Controllers.V1
|
||||
{
|
||||
#region Fields
|
||||
private readonly ILogger<SongController> _logger;
|
||||
private string _connectionString;
|
||||
private IConfiguration _config;
|
||||
private SongManager _songMgr;
|
||||
#endregion
|
||||
@@ -35,6 +36,7 @@ namespace Icarus.Controllers.V1
|
||||
public SongController(IConfiguration config, ILogger<SongController> logger)
|
||||
{
|
||||
_config = config;
|
||||
_connectionString = _config.GetConnectionString("DefaultConnection");
|
||||
_logger = logger;
|
||||
_songMgr = new SongManager(config);
|
||||
}
|
||||
@@ -49,10 +51,9 @@ namespace Icarus.Controllers.V1
|
||||
Console.WriteLine("Attemtping to retrieve songs");
|
||||
_logger.LogInformation("Attempting to retrieve songs");
|
||||
|
||||
SongRepository context = HttpContext.RequestServices
|
||||
.GetService(typeof(SongRepository)) as SongRepository;
|
||||
var context = new SongContext(_connectionString);
|
||||
|
||||
songs = context.GetAllSongs();
|
||||
songs = context.Songs.ToList();
|
||||
|
||||
if (songs.Count > 0)
|
||||
return Ok(songs);
|
||||
@@ -64,15 +65,14 @@ namespace Icarus.Controllers.V1
|
||||
[Authorize("read:song_details")]
|
||||
public IActionResult Get(int id)
|
||||
{
|
||||
SongRepository context = HttpContext.RequestServices
|
||||
.GetService(typeof(SongRepository)) as SongRepository;
|
||||
var context = new SongContext(_connectionString);
|
||||
|
||||
Song song = new Song { Id = id };
|
||||
song = context.GetSong(song);
|
||||
Song song = new Song { SongID = id };
|
||||
song = context.RetrieveRecord(song);
|
||||
|
||||
Console.WriteLine("Here");
|
||||
|
||||
if (song.Id != 0)
|
||||
if (song.SongID != 0)
|
||||
return Ok(song);
|
||||
else
|
||||
return NotFound();
|
||||
@@ -82,33 +82,19 @@ namespace Icarus.Controllers.V1
|
||||
[HttpPut("{id}")]
|
||||
public IActionResult Put(int id, [FromBody] Song song)
|
||||
{
|
||||
SongRepository context = HttpContext.RequestServices
|
||||
.GetService(typeof(SongRepository)) as SongRepository;
|
||||
var context = new SongContext(_connectionString);
|
||||
|
||||
ArtistRepository artistStore = HttpContext.RequestServices
|
||||
.GetService(typeof(ArtistRepository)) as ArtistRepository;
|
||||
|
||||
AlbumRepository albumStore = HttpContext.RequestServices
|
||||
.GetService(typeof(AlbumRepository)) as AlbumRepository;
|
||||
|
||||
GenreRepository genreStore = HttpContext.RequestServices
|
||||
.GetService(typeof(GenreRepository)) as GenreRepository;
|
||||
|
||||
YearRepository yearStore = HttpContext.RequestServices
|
||||
.GetService(typeof(YearRepository)) as YearRepository;
|
||||
|
||||
song.Id = id;
|
||||
song.SongID = id;
|
||||
Console.WriteLine("Retrieving filepath of song");
|
||||
_logger.LogInformation("Retrieving filepath of song");
|
||||
|
||||
if (!context.DoesSongExist(song))
|
||||
if (!context.DoesRecordExist(song))
|
||||
return NotFound(new SongResult
|
||||
{
|
||||
Message = "Song does not exist"
|
||||
});
|
||||
|
||||
var songRes = _songMgr.UpdateSong(song, context, albumStore, artistStore, genreStore,
|
||||
yearStore);
|
||||
var songRes = _songMgr.UpdateSong(song);
|
||||
|
||||
return Ok(songRes);
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ namespace Icarus.Controllers.V1
|
||||
public class SongDataController : ControllerBase
|
||||
{
|
||||
#region Fields
|
||||
private string _connectionString;
|
||||
private IConfiguration _config;
|
||||
private ILogger<SongDataController> _logger;
|
||||
private SongManager _songMgr;
|
||||
@@ -37,6 +38,7 @@ namespace Icarus.Controllers.V1
|
||||
public SongDataController(IConfiguration config, ILogger<SongDataController> logger)
|
||||
{
|
||||
_config = config;
|
||||
_connectionString = _config.GetConnectionString("DefaultConnection");
|
||||
_logger = logger;
|
||||
_songTempDir = _config.GetValue<string>("TemporaryMusicPath");
|
||||
_songMgr = new SongManager(config, _songTempDir);
|
||||
@@ -50,7 +52,8 @@ namespace Icarus.Controllers.V1
|
||||
[Authorize("download:songs")]
|
||||
public async Task<IActionResult> Get(int id)
|
||||
{
|
||||
var songMetaData = _songRepository.GetSong(id);
|
||||
var songContext = new SongContext(_connectionString);
|
||||
var songMetaData = songContext.RetrieveRecord(new Song { SongID = id});
|
||||
|
||||
SongData song = await _songMgr.RetrieveSong(songMetaData);
|
||||
|
||||
@@ -69,14 +72,13 @@ namespace Icarus.Controllers.V1
|
||||
var uploads = _songTempDir;
|
||||
Console.WriteLine($"Song Root Path {uploads}");
|
||||
_logger.LogInformation($"Song root path {uploads}");
|
||||
|
||||
foreach (var sng in songData)
|
||||
if (sng.Length > 0) {
|
||||
Console.WriteLine($"Song filename {sng.FileName}");
|
||||
_logger.LogInformation($"Song filename {sng.FileName}");
|
||||
|
||||
await _songMgr.SaveSongToFileSystem(sng, _songRepository,
|
||||
_albumRepository, _artistRepository,
|
||||
_genreRepository, _yearRepository, _coverArtRepository);
|
||||
await _songMgr.SaveSongToFileSystem(sng);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -90,9 +92,12 @@ namespace Icarus.Controllers.V1
|
||||
[Authorize("delete:songs")]
|
||||
public IActionResult Delete(int id)
|
||||
{
|
||||
var songContext = new SongContext(_connectionString);
|
||||
|
||||
var songMetaData = new Song{ SongID = id };
|
||||
Console.WriteLine($"Id {songMetaData.SongID}");
|
||||
songMetaData = _songRepository.GetSong(songMetaData);
|
||||
|
||||
songMetaData = songContext.RetrieveRecord(songMetaData);
|
||||
|
||||
if (string.IsNullOrEmpty(songMetaData.Title))
|
||||
{
|
||||
@@ -103,10 +108,7 @@ namespace Icarus.Controllers.V1
|
||||
{
|
||||
_logger.LogInformation("Starting process of deleting song from the filesystem and database");
|
||||
|
||||
_songMgr.DeleteSong(songMetaData, _songRepository,
|
||||
_albumRepository, _artistRepository,
|
||||
_genreRepository, _yearRepository,
|
||||
_coverArtRepository);
|
||||
_songMgr.DeleteSong(songMetaData);
|
||||
|
||||
return Ok();
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ namespace Icarus.Controllers.V1
|
||||
{
|
||||
#region Fields
|
||||
private ILogger<SongStreamController> _logger;
|
||||
private string _connectionString;
|
||||
private IConfiguration _config;
|
||||
#endregion
|
||||
|
||||
@@ -36,6 +37,7 @@ namespace Icarus.Controllers.V1
|
||||
{
|
||||
_logger = logger;
|
||||
_config = config;
|
||||
_connectionString = _config.GetConnectionString("DefaultConnection");
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -56,7 +58,11 @@ namespace Icarus.Controllers.V1
|
||||
_logger.LogInformation("Starting to stream song...>");
|
||||
Console.WriteLine("Starting to streamsong...");
|
||||
|
||||
return File(stream, "application/octet-stream", filename);
|
||||
var file = await Task.Run(() => {
|
||||
return File(stream, "application/octet-stream", filename);
|
||||
});
|
||||
|
||||
return file;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user