Refactoring and cleanup

This commit is contained in:
amazing-username
2019-04-14 18:53:04 +00:00
parent ed6ae7e3dd
commit c9b1abdbdb
10 changed files with 596 additions and 423 deletions
+24 -23
View File
@@ -10,6 +10,7 @@ using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;
using Icarus.Controllers.Managers;
using Icarus.Controllers.Utilities;
using Icarus.Models;
namespace Icarus.Controllers
@@ -20,41 +21,41 @@ namespace Icarus.Controllers
{
#region Fields
private IConfiguration _config;
private SongManager _songMgr;
private string _songTempDir;
private string _archiveDir;
#endregion
private SongManager _songMgr;
private string _songTempDir;
private string _archiveDir;
#endregion
#region Properties
#endregion
#region Properties
#endregion
#region Constructor
public SongCompressedDataController(IConfiguration config)
{
_config = config;
_songTempDir = _config.GetValue<string>("TemporaryMusicPath");
_archiveDir = _config.GetValue<string>("ArchivePath");
_songMgr = new SongManager(config, _songTempDir);
_songMgr.ArchiveDirectoryRoot = _archiveDir;
}
#endregion
#region Constructor
public SongCompressedDataController(IConfiguration config)
{
_config = config;
_songTempDir = _config.GetValue<string>("TemporaryMusicPath");
_archiveDir = _config.GetValue<string>("ArchivePath");
}
#endregion
#region API Routes
#region API Routes
[HttpGet("{id}")]
public async Task<IActionResult> Get(int id)
{
SongData song = new SongData();
MusicStoreContext context = HttpContext.RequestServices.GetService(typeof(MusicStoreContext)) as MusicStoreContext;
Console.WriteLine($"Archive directory root: {_archiveDir}");
SongCompression cmp = new SongCompression(_archiveDir);
Console.WriteLine($"Archive directory root: {_archiveDir}");
Console.WriteLine("Starting process of retrieving comrpessed song");
song = await _songMgr.RetrieveCompressedSong(id);
Console.WriteLine("Starting process of retrieving comrpessed song");
SongData song = await cmp.RetrieveCompressedSong(context.GetSong(id));
return File(song.Data, "application/x-msdownload", _songMgr.CompressedSongFilename);
return File(song.Data, "application/x-msdownload", cmp.CompressedSongFilename);
}
#endregion
#endregion
}
}