Added versioning to the API, created namespace for the Reposiorites, Changed the StoreContexts to Repositories, moved the Contexts class to another namespace. #37

This commit is contained in:
amazing-username
2019-05-28 23:36:56 +00:00
parent 9ad620db06
commit 42facee883
32 changed files with 183 additions and 167 deletions
+1 -1
View File
@@ -4,7 +4,7 @@ using System.Configuration;
using Icarus.Controllers.Utilities;
using Icarus.Models;
using Icarus.Models.Context;
using Icarus.Database.Contexts;
namespace Icarus.Controllers.Managers
{
+1 -1
View File
@@ -4,7 +4,7 @@ using System.Configuration;
using Icarus.Controllers.Utilities;
using Icarus.Models;
using Icarus.Models.Context;
using Icarus.Database.Contexts;
namespace Icarus.Controllers.Managers
{
+1 -1
View File
@@ -4,7 +4,7 @@ using System.Configuration;
using Icarus.Controllers.Utilities;
using Icarus.Models;
using Icarus.Models.Context;
using Icarus.Database.Contexts;
namespace Icarus.Controllers.Managers
{
+33 -32
View File
@@ -17,7 +17,8 @@ using TagLib;
using Icarus.Controllers.Utilities;
using Icarus.Models;
using Icarus.Models.Context;
using Icarus.Database.Contexts;
using Icarus.Database.Repositories;
namespace Icarus.Controllers.Managers
{
@@ -94,9 +95,9 @@ namespace Icarus.Controllers.Managers
#region Methods
public SongResult UpdateSong(Song song, MusicStoreContext songStore, AlbumStoreContext albumStore,
ArtistStoreContext artistStore, GenreStoreContext genreStore,
YearStoreContext yearStore)
public SongResult UpdateSong(Song song, SongRepository songStore, AlbumRepository albumStore,
ArtistRepository artistStore, GenreRepository genreStore,
YearRepository yearStore)
{
var result = new SongResult();
@@ -160,9 +161,9 @@ namespace Icarus.Controllers.Managers
return successful;
}
public void DeleteSong(Song song, MusicStoreContext songStore,
AlbumStoreContext albumStore, ArtistStoreContext artistStore,
GenreStoreContext genreStore, YearStoreContext yearStore)
public void DeleteSong(Song song, SongRepository songStore,
AlbumRepository albumStore, ArtistRepository artistStore,
GenreRepository genreStore, YearRepository yearStore)
{
try
{
@@ -303,9 +304,9 @@ namespace Icarus.Controllers.Managers
Console.WriteLine($"An error occurred: {exMsg}");
}
}
public async Task SaveSongToFileSystem(IFormFile songFile, MusicStoreContext sStoreContext,
AlbumStoreContext alStoreContext,
ArtistStoreContext arStoreContext)
public async Task SaveSongToFileSystem(IFormFile songFile, SongRepository sStoreContext,
AlbumRepository alStoreContext,
ArtistRepository arStoreContext)
{
try
{
@@ -339,9 +340,9 @@ namespace Icarus.Controllers.Managers
_logger.Error(msg, "An error occurred");
}
}
public async Task SaveSongToFileSystem(IFormFile songFile, MusicStoreContext songStore,
AlbumStoreContext albumStore, ArtistStoreContext artistStore,
GenreStoreContext genreStore, YearStoreContext yearStore)
public async Task SaveSongToFileSystem(IFormFile songFile, SongRepository songStore,
AlbumRepository albumStore, ArtistRepository artistStore,
GenreRepository genreStore, YearRepository yearStore)
{
try
{
@@ -634,8 +635,8 @@ namespace Icarus.Controllers.Managers
_results = new DataTable();
}
private void SaveSongToDatabase(Song song, MusicStoreContext songStore, AlbumStoreContext albumStore,
ArtistStoreContext artistStore)
private void SaveSongToDatabase(Song song, SongRepository songStore, AlbumRepository albumStore,
ArtistRepository artistStore)
{
_logger.Info("Starting process to save the song to the database");
@@ -649,8 +650,8 @@ namespace Icarus.Controllers.Managers
songStore.SaveSong(song);
}
private void SaveSongToDatabase(Song song, MusicStoreContext songStore, AlbumStoreContext albumStore,
ArtistStoreContext artistStore, GenreStoreContext genreStore, YearStoreContext yearStore)
private void SaveSongToDatabase(Song song, SongRepository songStore, AlbumRepository albumStore,
ArtistRepository artistStore, GenreRepository genreStore, YearRepository yearStore)
{
_logger.Info("Starting process to save the song to the database");
@@ -664,7 +665,7 @@ namespace Icarus.Controllers.Managers
_logger.Info(info);
songStore.SaveSong(song);
}
private void SaveAlbumToDatabase(ref Song song, AlbumStoreContext albumStore)
private void SaveAlbumToDatabase(ref Song song, AlbumRepository albumStore)
{
_logger.Info("Starting process to save the album record of the song to the database");
@@ -691,7 +692,7 @@ namespace Icarus.Controllers.Managers
song.AlbumId = album.AlbumId;
}
private void SaveArtistToDatabase(ref Song song, ArtistStoreContext artistStore)
private void SaveArtistToDatabase(ref Song song, ArtistRepository artistStore)
{
_logger.Info("Starting process to save the artist record of the song to the database");
@@ -717,7 +718,7 @@ namespace Icarus.Controllers.Managers
song.ArtistId = artist.ArtistId;
}
private void SaveGenreToDatabase(ref Song song, GenreStoreContext genreStore)
private void SaveGenreToDatabase(ref Song song, GenreRepository genreStore)
{
_logger.Info("Starting process to save the genre record of the song to the database");
@@ -748,7 +749,7 @@ namespace Icarus.Controllers.Managers
song.GenreId = genre.GenreId;
}
private void SaveYearToDatabase(ref Song song, YearStoreContext yearStore)
private void SaveYearToDatabase(ref Song song, YearRepository yearStore)
{
_logger.Info("Starting process to save the year record of the song to the database");
@@ -812,7 +813,7 @@ namespace Icarus.Controllers.Managers
return true;
}
private Album UpdateAlbumInDatabase(Song oldSongRecord, Song newSongRecord, AlbumStoreContext albumStore)
private Album UpdateAlbumInDatabase(Song oldSongRecord, Song newSongRecord, AlbumRepository albumStore)
{
var albumRecord = albumStore.GetAlbum(oldSongRecord, true);
var oldAlbumTitle = oldSongRecord.AlbumTitle;
@@ -867,7 +868,7 @@ namespace Icarus.Controllers.Managers
return existingAlbumRecord;
}
}
private Artist UpdateArtistInDatabase(Song oldSongRecord, Song newSongRecord, ArtistStoreContext artistStore)
private Artist UpdateArtistInDatabase(Song oldSongRecord, Song newSongRecord, ArtistRepository artistStore)
{
var oldArtistRecord = artistStore.GetArtist(oldSongRecord, true);
var oldArtistName = oldArtistRecord.Name;
@@ -912,7 +913,7 @@ namespace Icarus.Controllers.Managers
return existingArtistRecord;
}
}
private Genre UpdateGenreInDatabase(Song oldSongRecord, Song newSongRecord, GenreStoreContext genreStore)
private Genre UpdateGenreInDatabase(Song oldSongRecord, Song newSongRecord, GenreRepository genreStore)
{
var oldGenreRecord = genreStore.GetGenre(oldSongRecord, true);
var oldGenreName = oldGenreRecord.GenreName;
@@ -956,7 +957,7 @@ namespace Icarus.Controllers.Managers
return genreStore.GetGenre(existingGenreRecord);
}
}
private Year UpdateYearInDatabase(Song oldSongRecord, Song newSongRecord, YearStoreContext yearStore)
private Year UpdateYearInDatabase(Song oldSongRecord, Song newSongRecord, YearRepository yearStore)
{
var oldYearRecord = yearStore.GetSongYear(oldSongRecord, true);
var oldYearValue = oldYearRecord.YearValue;
@@ -1001,7 +1002,7 @@ namespace Icarus.Controllers.Managers
return existingYearRecord;
}
}
private void UpdateSongInDatabase(ref Song oldSongRecord, ref Song newSongRecord, MusicStoreContext songStore,
private void UpdateSongInDatabase(ref Song oldSongRecord, ref Song newSongRecord, SongRepository songStore,
ref SongResult result)
{
var updatedSongRecord = new Song
@@ -1111,8 +1112,8 @@ namespace Icarus.Controllers.Managers
result.SongTitle = updatedSongRecord.Title;
}
private void DeleteSongFromDatabase(Song song, MusicStoreContext songStore, AlbumStoreContext albumStore,
ArtistStoreContext artistStore, GenreStoreContext genreStore, YearStoreContext yearStore)
private void DeleteSongFromDatabase(Song song, SongRepository songStore, AlbumRepository albumStore,
ArtistRepository artistStore, GenreRepository genreStore, YearRepository yearStore)
{
_logger.Info("Starting process to delete records related to the song from the database");
@@ -1123,7 +1124,7 @@ namespace Icarus.Controllers.Managers
songStore.DeleteSong(song);
}
private void DeleteAlbumFromDatabase(Song song, AlbumStoreContext albumStore)
private void DeleteAlbumFromDatabase(Song song, AlbumRepository albumStore)
{
if (!albumStore.DoesAlbumExist(song))
{
@@ -1138,7 +1139,7 @@ namespace Icarus.Controllers.Managers
albumStore.DeleteAlbum(album);
}
}
private void DeleteArtistFromDatabase(Song song, ArtistStoreContext artistStore)
private void DeleteArtistFromDatabase(Song song, ArtistRepository artistStore)
{
if (!artistStore.DoesArtistExist(song))
{
@@ -1153,7 +1154,7 @@ namespace Icarus.Controllers.Managers
artistStore.DeleteArtist(artist);
}
}
private void DeleteGenreFromDatabase(Song song, GenreStoreContext genreStore)
private void DeleteGenreFromDatabase(Song song, GenreRepository genreStore)
{
if (!genreStore.DoesGenreExist(song))
{
@@ -1168,7 +1169,7 @@ namespace Icarus.Controllers.Managers
genreStore.DeleteGenre(genre);
}
}
private void DeleteYearFromDatabase(Song song, YearStoreContext yearStore)
private void DeleteYearFromDatabase(Song song, YearRepository yearStore)
{
if (!yearStore.DoesYearExist(song))
{
+17 -1
View File
@@ -10,7 +10,7 @@ using Icarus.Models;
namespace Icarus.Controllers.Managers
{
public class TokenManager
public class TokenManager : BaseManager
{
#region Fields
private IConfiguration _config;
@@ -38,20 +38,30 @@ namespace Icarus.Controllers.Managers
#region Methods
public LoginResult RetrieveLoginResult(User user)
{
_logger.Info("Preparing Auth0 API request");
var client = new RestClient(_url);
var request = new RestRequest("oauth/token", Method.POST);
var tokenRequest = RetrieveTokenRequest();
_logger.Info("Serializing token object into JSON");
var tokenObject = JsonConvert.SerializeObject(tokenRequest);
Console.WriteLine(tokenObject);
request.AddParameter("application/json; charset=utf-8",
tokenObject, ParameterType.RequestBody);
request.RequestFormat = DataFormat.Json;
_logger.Info("Sending request");
IRestResponse response = client.Execute(request);
_logger.Info("Response received");
_logger.Info("Deserializing response");
var tokenResult = JsonConvert
.DeserializeObject<Token>(response.Content);
_logger.Info("Response deserialized");
Console.WriteLine(response.Content);
return new LoginResult
{
@@ -66,6 +76,8 @@ namespace Icarus.Controllers.Managers
private TokenRequest RetrieveTokenRequest()
{
_logger.Info("Retrieving token object");
return new TokenRequest
{
ClientId = _clientId,
@@ -77,12 +89,16 @@ namespace Icarus.Controllers.Managers
private void InitializeValues()
{
_logger.Info("Analyzing Auth0 information");
_clientId = _config["Auth0:ClientId"];
_clientSecret = _config["Auth0:ClientSecret"];
_audience = _config["Auth0:ApiIdentifier"];
_grantType = "client_credentials";
_url = $"https://{_config["Auth0:Domain"]}";
PrintCredentials();
}
#region Testing Methods
+1 -1
View File
@@ -4,7 +4,7 @@ using System.Configuration;
using Icarus.Controllers.Utilities;
using Icarus.Models;
using Icarus.Models.Context;
using Icarus.Database.Contexts;
namespace Icarus.Controllers.Managers
{
@@ -8,11 +8,11 @@ using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
using Icarus.Models;
using Icarus.Models.Context;
using Icarus.Database.Repositories;
namespace Icarus.Controllers
namespace Icarus.Controllers.V1
{
[Route("api/album")]
[Route("api/v1/album")]
[ApiController]
public class AlbumController : ControllerBase
{
@@ -40,9 +40,9 @@ namespace Icarus.Controllers
{
List<Album> albums = new List<Album>();
AlbumStoreContext albumStoreContext = HttpContext
AlbumRepository albumStoreContext = HttpContext
.RequestServices
.GetService(typeof(AlbumStoreContext)) as AlbumStoreContext;
.GetService(typeof(AlbumRepository)) as AlbumRepository;
albums = albumStoreContext.GetAlbums();
@@ -65,9 +65,9 @@ namespace Icarus.Controllers
AlbumId = id
};
AlbumStoreContext albumStoreContext = HttpContext
AlbumRepository albumStoreContext = HttpContext
.RequestServices
.GetService(typeof(AlbumStoreContext)) as AlbumStoreContext;
.GetService(typeof(AlbumRepository)) as AlbumRepository;
if (albumStoreContext.DoesAlbumExist(album))
{
@@ -9,11 +9,11 @@ using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
using Icarus.Models;
using Icarus.Models.Context;
using Icarus.Database.Repositories;
namespace Icarus.Controllers
namespace Icarus.Controllers.V1
{
[Route("api/artist")]
[Route("api/v1/artist")]
[ApiController]
public class ArtistController : ControllerBase
{
@@ -39,9 +39,9 @@ namespace Icarus.Controllers
[Authorize("read:artists")]
public IActionResult Get()
{
ArtistStoreContext artistStoreContext = HttpContext
ArtistRepository artistStoreContext = HttpContext
.RequestServices
.GetService(typeof(ArtistStoreContext)) as ArtistStoreContext;
.GetService(typeof(ArtistRepository)) as ArtistRepository;
var artists = artistStoreContext.GetArtists();
@@ -64,9 +64,9 @@ namespace Icarus.Controllers
ArtistId = id
};
ArtistStoreContext artistStoreContext = HttpContext
ArtistRepository artistStoreContext = HttpContext
.RequestServices
.GetService(typeof(ArtistStoreContext)) as ArtistStoreContext;
.GetService(typeof(ArtistRepository)) as ArtistRepository;
if (artistStoreContext.DoesArtistExist(artist))
{
@@ -7,11 +7,11 @@ using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
using Icarus.Models;
using Icarus.Models.Context;
using Icarus.Database.Repositories;
namespace Icarus.Controllers
namespace Icarus.Controllers.V1
{
[Route("api/genre")]
[Route("api/v1/genre")]
[ApiController]
public class GenreController : ControllerBase
{
@@ -40,7 +40,7 @@ namespace Icarus.Controllers
var genreStore = HttpContext
.RequestServices
.GetService(typeof(GenreStoreContext)) as GenreStoreContext;
.GetService(typeof(GenreRepository)) as GenreRepository;
genres = genreStore.GetGenres();
@@ -64,7 +64,7 @@ namespace Icarus.Controllers
var genreStore = HttpContext
.RequestServices
.GetService(typeof(GenreStoreContext)) as GenreStoreContext;
.GetService(typeof(GenreRepository)) as GenreRepository;
if (genreStore.DoesGenreExist(genre))
{
@@ -11,11 +11,11 @@ using Microsoft.Extensions.Logging;
using Icarus.Controllers.Managers;
using Icarus.Controllers.Utilities;
using Icarus.Models;
using Icarus.Models.Context;
using Icarus.Database.Repositories;
namespace Icarus.Controllers
namespace Icarus.Controllers.V1
{
[Route("api/login")]
[Route("api/v1/login")]
[ApiController]
public class LoginController : ControllerBase
{
@@ -41,9 +41,9 @@ namespace Icarus.Controllers
#region HTTP endpoints
public IActionResult Post([FromBody] User user)
{
UserStoreContext context = HttpContext
UserRepository context = HttpContext
.RequestServices
.GetService(typeof(UserStoreContext)) as UserStoreContext;
.GetService(typeof(UserRepository)) as UserRepository;
_logger.LogInformation("Starting process of validating credentials");
@@ -10,11 +10,11 @@ using Microsoft.Extensions.Configuration;
using Icarus.Controllers.Managers;
using Icarus.Controllers.Utilities;
using Icarus.Models;
using Icarus.Models.Context;
using Icarus.Database.Repositories;
namespace Icarus.Controllers
namespace Icarus.Controllers.V1
{
[Route("api/register")]
[Route("api/v1/register")]
[ApiController]
public class RegisterController : ControllerBase
{
@@ -41,9 +41,9 @@ namespace Icarus.Controllers
user.Password = pe.HashPassword(user);
user.EmailVerified = false;
UserStoreContext context = HttpContext
UserRepository context = HttpContext
.RequestServices
.GetService(typeof(UserStoreContext)) as UserStoreContext;
.GetService(typeof(UserRepository)) as UserRepository;
context.SaveUser(user);
@@ -13,11 +13,11 @@ using Microsoft.Extensions.Configuration;
using Icarus.Controllers.Managers;
using Icarus.Controllers.Utilities;
using Icarus.Models;
using Icarus.Models.Context;
using Icarus.Database.Repositories;
namespace Icarus.Controllers
namespace Icarus.Controllers.V1
{
[Route("api/song/compressed/data")]
[Route("api/v1/song/compressed/data")]
[ApiController]
public class SongCompressedDataController : ControllerBase
{
@@ -48,9 +48,9 @@ namespace Icarus.Controllers
[Authorize("download:songs")]
public async Task<IActionResult> Get(int id)
{
MusicStoreContext context = HttpContext
SongRepository context = HttpContext
.RequestServices
.GetService(typeof(MusicStoreContext)) as MusicStoreContext;
.GetService(typeof(SongRepository)) as SongRepository;
SongCompression cmp = new SongCompression(_archiveDir);
@@ -12,11 +12,11 @@ using Microsoft.Extensions.Logging;
using Icarus.Controllers.Managers;
using Icarus.Controllers.Utilities;
using Icarus.Models;
using Icarus.Models.Context;
using Icarus.Database.Repositories;
namespace Icarus.Controllers
namespace Icarus.Controllers.V1
{
[Route("api/song")]
[Route("api/v1/song")]
[ApiController]
public class SongController : ControllerBase
{
@@ -49,9 +49,9 @@ namespace Icarus.Controllers
Console.WriteLine("Attemtping to retrieve songs");
_logger.LogInformation("Attempting to retrieve songs");
MusicStoreContext context = HttpContext
SongRepository context = HttpContext
.RequestServices
.GetService(typeof(MusicStoreContext)) as MusicStoreContext;
.GetService(typeof(SongRepository)) as SongRepository;
songs = context.GetAllSongs();
@@ -69,9 +69,9 @@ namespace Icarus.Controllers
[Authorize("read:song_details")]
public IActionResult Get(int id)
{
MusicStoreContext context = HttpContext
SongRepository context = HttpContext
.RequestServices
.GetService(typeof(MusicStoreContext)) as MusicStoreContext;
.GetService(typeof(SongRepository)) as SongRepository;
Song song = new Song { Id = id };
song = context.GetSong(song);
@@ -92,25 +92,25 @@ namespace Icarus.Controllers
[HttpPut("{id}")]
public IActionResult Put(int id, [FromBody] Song song)
{
MusicStoreContext context = HttpContext
SongRepository context = HttpContext
.RequestServices
.GetService(typeof(MusicStoreContext)) as MusicStoreContext;
.GetService(typeof(SongRepository)) as SongRepository;
ArtistStoreContext artistStore = HttpContext
ArtistRepository artistStore = HttpContext
.RequestServices
.GetService(typeof(ArtistStoreContext)) as ArtistStoreContext;
.GetService(typeof(ArtistRepository)) as ArtistRepository;
AlbumStoreContext albumStore = HttpContext
AlbumRepository albumStore = HttpContext
.RequestServices
.GetService(typeof(AlbumStoreContext)) as AlbumStoreContext;
.GetService(typeof(AlbumRepository)) as AlbumRepository;
GenreStoreContext genreStore = HttpContext
GenreRepository genreStore = HttpContext
.RequestServices
.GetService(typeof(GenreStoreContext)) as GenreStoreContext;
.GetService(typeof(GenreRepository)) as GenreRepository;
YearStoreContext yearStore = HttpContext
YearRepository yearStore = HttpContext
.RequestServices
.GetService(typeof(YearStoreContext)) as YearStoreContext;
.GetService(typeof(YearRepository)) as YearRepository;
song.Id = id;
Console.WriteLine("Retrieving filepath of song");
@@ -13,11 +13,11 @@ using Microsoft.Extensions.Logging;
using Icarus.Controllers.Managers;
using Icarus.Models;
using Icarus.Models.Context;
using Icarus.Database.Repositories;
namespace Icarus.Controllers
namespace Icarus.Controllers.V1
{
[Route("api/song/data")]
[Route("api/v1/song/data")]
[ApiController]
public class SongDataController : ControllerBase
{
@@ -49,9 +49,9 @@ namespace Icarus.Controllers
[Authorize("download:songs")]
public async Task<IActionResult> Get(int id)
{
MusicStoreContext context = HttpContext
SongRepository context = HttpContext
.RequestServices
.GetService(typeof(MusicStoreContext)) as MusicStoreContext;
.GetService(typeof(SongRepository)) as SongRepository;
var songMetaData = context.GetSong(id);
SongData song = await _songMgr.RetrieveSong(songMetaData);
@@ -65,21 +65,21 @@ namespace Icarus.Controllers
{
try
{
MusicStoreContext songStoreContext = HttpContext
SongRepository songRepository = HttpContext
.RequestServices
.GetService(typeof(MusicStoreContext)) as MusicStoreContext;
AlbumStoreContext albumStoreContext = HttpContext
.GetService(typeof(SongRepository)) as SongRepository;
AlbumRepository albumStoreContext = HttpContext
.RequestServices
.GetService(typeof(AlbumStoreContext)) as AlbumStoreContext;
ArtistStoreContext artistStoreContext = HttpContext
.GetService(typeof(AlbumRepository)) as AlbumRepository;
ArtistRepository artistStoreContext = HttpContext
.RequestServices
.GetService(typeof(ArtistStoreContext)) as ArtistStoreContext;
GenreStoreContext genreStore = HttpContext
.GetService(typeof(ArtistRepository)) as ArtistRepository;
GenreRepository genreStore = HttpContext
.RequestServices
.GetService(typeof(GenreStoreContext)) as GenreStoreContext;
YearStoreContext yearStore = HttpContext
.GetService(typeof(GenreRepository)) as GenreRepository;
YearRepository yearStore = HttpContext
.RequestServices
.GetService(typeof(YearStoreContext)) as YearStoreContext;
.GetService(typeof(YearRepository)) as YearRepository;
Console.WriteLine("Uploading song...");
_logger.LogInformation("Uploading song...");
@@ -93,7 +93,7 @@ namespace Icarus.Controllers
Console.WriteLine($"Song filename {sng.FileName}");
_logger.LogInformation($"Song filename {sng.FileName}");
await _songMgr.SaveSongToFileSystem(sng, songStoreContext,
await _songMgr.SaveSongToFileSystem(sng, songRepository,
albumStoreContext, artistStoreContext,
genreStore, yearStore);
}
@@ -110,21 +110,21 @@ namespace Icarus.Controllers
[Authorize("delete:songs")]
public IActionResult Delete(int id)
{
MusicStoreContext context = HttpContext
SongRepository context = HttpContext
.RequestServices
.GetService(typeof(MusicStoreContext)) as MusicStoreContext;
AlbumStoreContext albumStore = HttpContext
.GetService(typeof(SongRepository)) as SongRepository;
AlbumRepository albumStore = HttpContext
.RequestServices
.GetService(typeof(AlbumStoreContext)) as AlbumStoreContext;
ArtistStoreContext artistStore = HttpContext
.GetService(typeof(AlbumRepository)) as AlbumRepository;
ArtistRepository artistStore = HttpContext
.RequestServices
.GetService(typeof(ArtistStoreContext)) as ArtistStoreContext;
GenreStoreContext genreStore = HttpContext
.GetService(typeof(ArtistRepository)) as ArtistRepository;
GenreRepository genreStore = HttpContext
.RequestServices
.GetService(typeof(GenreStoreContext)) as GenreStoreContext;
YearStoreContext yearStore = HttpContext
.GetService(typeof(GenreRepository)) as GenreRepository;
YearRepository yearStore = HttpContext
.RequestServices
.GetService(typeof(YearStoreContext)) as YearStoreContext;
.GetService(typeof(YearRepository)) as YearRepository;
var songMetaData = new Song{ Id = id };
Console.WriteLine($"Id {songMetaData.Id}");
@@ -12,11 +12,11 @@ using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using Icarus.Models;
using Icarus.Models.Context;
using Icarus.Database.Repositories;
namespace Icarus.Controllers
namespace Icarus.Controllers.V1
{
[Route("api/song/stream")]
[Route("api/v1/song/stream")]
[ApiController]
public class SongStreamController : ControllerBase
{
@@ -43,7 +43,7 @@ namespace Icarus.Controllers
{
var songStore= HttpContext
.RequestServices
.GetService(typeof(MusicStoreContext)) as MusicStoreContext;
.GetService(typeof(SongRepository)) as SongRepository;
var song = songStore.GetSong(new Song { Id = id });
@@ -7,11 +7,11 @@ using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
using Icarus.Models;
using Icarus.Models.Context;
using Icarus.Database.Repositories;
namespace Icarus.Controller
namespace Icarus.Controller.V1
{
[Route("api/year")]
[Route("api/v1/year")]
[ApiController]
public class YearController : ControllerBase
{
@@ -40,7 +40,7 @@ namespace Icarus.Controller
var yearStore = HttpContext
.RequestServices
.GetService(typeof(YearStoreContext)) as YearStoreContext;
.GetService(typeof(YearRepository)) as YearRepository;
yearValues = yearStore.GetSongYears();
@@ -64,7 +64,7 @@ namespace Icarus.Controller
var yearStore = HttpContext
.RequestServices
.GetService(typeof(YearStoreContext)) as YearStoreContext;
.GetService(typeof(YearRepository)) as YearRepository;
if (yearStore.DoesYearExist(year))
{