#74: Some cleanup
This commit is contained in:
@@ -1,11 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
using Icarus.Models;
|
||||
using Icarus.Database.Contexts;
|
||||
@@ -41,11 +35,9 @@ public class AlbumController : BaseController
|
||||
[HttpGet]
|
||||
public IActionResult GetAlbums()
|
||||
{
|
||||
List<Album> albums = new List<Album>();
|
||||
|
||||
var albumContext = new AlbumContext(_connectionString);
|
||||
|
||||
albums = albumContext.Albums.ToList();
|
||||
var albums = albumContext.Albums.ToList();
|
||||
|
||||
if (albums.Count > 0)
|
||||
return Ok(albums);
|
||||
@@ -56,10 +48,7 @@ public class AlbumController : BaseController
|
||||
[HttpGet("{id}")]
|
||||
public IActionResult GetAlbum(int id)
|
||||
{
|
||||
Album album = new Album
|
||||
{
|
||||
AlbumID = id
|
||||
};
|
||||
Album album = new Album{ AlbumID = id };
|
||||
|
||||
var albumContext = new AlbumContext(_connectionString);
|
||||
|
||||
|
||||
@@ -1,10 +1,5 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
using Icarus.Models;
|
||||
using Icarus.Database.Contexts;
|
||||
@@ -67,7 +62,9 @@ public class ArtistController : BaseController
|
||||
return Ok(artist);
|
||||
}
|
||||
else
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
@@ -1,8 +1,4 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
|
||||
|
||||
namespace Icarus.Controllers.V1;
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
using Icarus.Models;
|
||||
using Icarus.Database.Contexts;
|
||||
@@ -41,25 +35,24 @@ public class GenreController : BaseController
|
||||
[HttpGet]
|
||||
public IActionResult GetGenres()
|
||||
{
|
||||
var genres = new List<Genre>();
|
||||
|
||||
var genreStore = new GenreContext(_connectionString);
|
||||
|
||||
genres = genreStore.Genres.ToList();
|
||||
var genres = genreStore.Genres.ToList();
|
||||
|
||||
if (genres.Count > 0)
|
||||
{
|
||||
return Ok(genres);
|
||||
}
|
||||
else
|
||||
{
|
||||
return NotFound(new List<Genre>());
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet("{id}")]
|
||||
public IActionResult GetGenre(int id)
|
||||
{
|
||||
var genre = new Genre
|
||||
{
|
||||
GenreID = id
|
||||
};
|
||||
var genre = new Genre{ GenreID = id };
|
||||
|
||||
var genreStore = new GenreContext(_connectionString);
|
||||
|
||||
@@ -70,7 +63,9 @@ public class GenreController : BaseController
|
||||
return Ok(genre);
|
||||
}
|
||||
else
|
||||
{
|
||||
return NotFound(new Genre());
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
@@ -1,13 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
|
||||
using Icarus.Controllers.Managers;
|
||||
using Icarus.Controllers.Utilities;
|
||||
using Icarus.Models;
|
||||
using Icarus.Database.Contexts;
|
||||
@@ -19,7 +11,6 @@ namespace Icarus.Controllers.V1;
|
||||
public class RegisterController : ControllerBase
|
||||
{
|
||||
#region Fields
|
||||
private string _connectionString;
|
||||
private IConfiguration _config;
|
||||
#endregion
|
||||
|
||||
@@ -32,7 +23,6 @@ public class RegisterController : ControllerBase
|
||||
public RegisterController(IConfiguration config)
|
||||
{
|
||||
_config = config;
|
||||
_connectionString = _config.GetConnectionString("DefaultConnection");
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -42,7 +42,6 @@ public class SongCompressedDataController : BaseController
|
||||
var context = new SongContext(_connectionString);
|
||||
|
||||
SongCompression cmp = new SongCompression(_archiveDir);
|
||||
|
||||
|
||||
Console.WriteLine($"Archive directory root: {_archiveDir}");
|
||||
|
||||
|
||||
@@ -1,16 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
using Icarus.Controllers.Managers;
|
||||
using Icarus.Controllers.Utilities;
|
||||
using Icarus.Models;
|
||||
using Icarus.Database.Contexts;
|
||||
|
||||
@@ -36,8 +27,8 @@ public class SongController : BaseController
|
||||
public SongController(IConfiguration config, ILogger<SongController> logger)
|
||||
{
|
||||
_config = config;
|
||||
_connectionString = _config.GetConnectionString("DefaultConnection");
|
||||
_logger = logger;
|
||||
_connectionString = _config.GetConnectionString("DefaultConnection");
|
||||
_songMgr = new SongManager(config);
|
||||
}
|
||||
#endregion
|
||||
@@ -45,23 +36,24 @@ public class SongController : BaseController
|
||||
|
||||
#region Methods
|
||||
#region HTTP Endpoints
|
||||
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult GetSongs()
|
||||
{
|
||||
List<Song> songs = new List<Song>();
|
||||
Console.WriteLine("Attemtping to retrieve songs");
|
||||
_logger.LogInformation("Attempting to retrieve songs");
|
||||
|
||||
var context = new SongContext(_connectionString);
|
||||
|
||||
songs = context.Songs.ToList();
|
||||
var songs = context.Songs.ToList();
|
||||
|
||||
if (songs.Count > 0)
|
||||
{
|
||||
return Ok(songs);
|
||||
}
|
||||
else
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet("{id}")]
|
||||
@@ -69,8 +61,7 @@ public class SongController : BaseController
|
||||
{
|
||||
var context = new SongContext(_connectionString);
|
||||
|
||||
Song song = new Song { SongID = id };
|
||||
song = context.RetrieveRecord(song);
|
||||
var song = context.RetrieveRecord(new Song{ SongID = id });
|
||||
|
||||
Console.WriteLine("Here");
|
||||
|
||||
@@ -83,8 +74,6 @@ public class SongController : BaseController
|
||||
[HttpPut("{id}")]
|
||||
public IActionResult UpdateSong(int id, [FromBody] Song song)
|
||||
{
|
||||
var context = new SongContext(_connectionString);
|
||||
|
||||
song.SongID = id;
|
||||
Console.WriteLine("Retrieving filepath of song");
|
||||
_logger.LogInformation("Retrieving filepath of song");
|
||||
|
||||
@@ -1,19 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Web;
|
||||
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 Icarus.Models;
|
||||
using Icarus.Controllers.Managers;
|
||||
using Icarus.Database.Contexts;
|
||||
|
||||
namespace Icarus.Controllers.V1;
|
||||
@@ -25,7 +12,6 @@ public class SongStreamController : BaseController
|
||||
{
|
||||
#region Fields
|
||||
private ILogger<SongStreamController> _logger;
|
||||
private string _connectionString;
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -38,7 +24,6 @@ public class SongStreamController : BaseController
|
||||
{
|
||||
_logger = logger;
|
||||
_config = config;
|
||||
_connectionString = _config.GetConnectionString("DefaultConnection");
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -63,11 +48,9 @@ public class SongStreamController : BaseController
|
||||
_logger.LogInformation("Starting to stream song...>");
|
||||
Console.WriteLine("Starting to streamsong...");
|
||||
|
||||
var file = await Task.Run(() => {
|
||||
return await Task.Run(() => {
|
||||
return File(stream, "application/octet-stream", filename);
|
||||
});
|
||||
|
||||
return file;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user