Code cleanup and conforming to a coding covention

This commit is contained in:
amazing-username
2019-07-04 17:19:40 -04:00
parent ada8fa79d3
commit 56fe805f80
28 changed files with 4274 additions and 4465 deletions
+33 -36
View File
@@ -16,52 +16,49 @@ using Icarus.Database.Repositories;
namespace Icarus.Controllers.V1
{
[Route("api/v1/song/stream")]
[ApiController]
public class SongStreamController : ControllerBase
{
#region Fields
private ILogger<SongStreamController> _logger;
#endregion
[Route("api/v1/song/stream")]
[ApiController]
public class SongStreamController : ControllerBase
{
#region Fields
private ILogger<SongStreamController> _logger;
#endregion
#region Properties
#endregion
#region Properties
#endregion
#region Constructor
public SongStreamController(ILogger<SongStreamController> logger)
{
_logger = logger;
}
#endregion
#region Constructor
public SongStreamController(ILogger<SongStreamController> logger)
{
_logger = logger;
}
#endregion
#region HTTP endpoints
[HttpGet("{id}")]
[Authorize("stream:songs")]
public async Task<IActionResult> Get(int id)
{
var songStore= HttpContext
.RequestServices
.GetService(typeof(SongRepository)) as SongRepository;
#region HTTP endpoints
[HttpGet("{id}")]
[Authorize("stream:songs")]
public async Task<IActionResult> Get(int id)
{
var songStore= HttpContext.RequestServices
.GetService(typeof(SongRepository)) as SongRepository;
var song = songStore.GetSong(new Song { Id = id });
var song = songStore.GetSong(new Song { Id = id });
var mem = new MemoryStream();
var mem = new MemoryStream();
using (var stream = new FileStream(song.SongPath, FileMode.Open, FileAccess.Read))
{
await stream.CopyToAsync(mem);
}
using (var stream = new FileStream(song.SongPath, FileMode.Open, FileAccess.Read))
await stream.CopyToAsync(mem);
mem.Position = 0;
mem.Position = 0;
_logger.LogInformation("Starting to stream song...>");
Console.WriteLine("Starting to streamsong...");
_logger.LogInformation("Starting to stream song...>");
Console.WriteLine("Starting to streamsong...");
return File(mem, "application/octet-stream", Path.GetFileName(song.SongPath));
}
#endregion
}
return File(mem, "application/octet-stream", Path.GetFileName(song.SongPath));
}
#endregion
}
}