diff --git a/Controllers/AlbumController.cs b/Controllers/AlbumController.cs index 9481c9b..c887945 100644 --- a/Controllers/AlbumController.cs +++ b/Controllers/AlbumController.cs @@ -44,23 +44,38 @@ namespace Icarus.Controllers albums = albumStoreContext.GetAlbums(); - - return Ok(albums); + if (albums.Count > 0) + { + return Ok(albums); + } + else + { + return NotFound(); + } } [HttpGet("{id}")] public IActionResult Get(int id) { - Album album = new Album(); - album.AlbumId = id; + Album album = new Album + { + AlbumId = id + }; AlbumStoreContext albumStoreContext = HttpContext .RequestServices .GetService(typeof(AlbumStoreContext)) as AlbumStoreContext; - album = albumStoreContext.GetAlbum(album); + if (albumStoreContext.DoesAlbumExist(album)) + { + album = albumStoreContext.GetAlbum(album); - return Ok(album); + return Ok(album); + } + else + { + return NotFound(); + } } #endregion } diff --git a/Models/Context/AlbumStoreContext.cs b/Models/Context/AlbumStoreContext.cs index c34a1b8..9a8a47c 100644 --- a/Models/Context/AlbumStoreContext.cs +++ b/Models/Context/AlbumStoreContext.cs @@ -172,7 +172,7 @@ namespace Icarus.Models.Context { album = ParseSingleData(reader); - if (album != null) + if (album.Title != null) { _logger.Info($"Album {album.Title} exists"); return true;