From 55613cbd825df293105e190bec6adce1a35f7a47 Mon Sep 17 00:00:00 2001 From: Dave Walker Date: Thu, 9 Nov 2023 08:26:38 +0000 Subject: [PATCH] Added album deletion endpoint --- docker/api/Dockerfile | 4 ++-- .../Controllers/AlbumsController.cs | 16 ++++++++++++++++ src/MusicCatalogue.Api/MusicCatalogue.Api.csproj | 6 +++--- 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/docker/api/Dockerfile b/docker/api/Dockerfile index 13e371f..c2c2f73 100644 --- a/docker/api/Dockerfile +++ b/docker/api/Dockerfile @@ -1,4 +1,4 @@ FROM mcr.microsoft.com/dotnet/core/aspnet:latest -COPY musiccatalogue.api-1.7.0.0 /opt/musiccatalogue.api-1.7.0.0 -WORKDIR /opt/musiccatalogue.api-1.7.0.0/bin +COPY musiccatalogue.api-1.8.0.0 /opt/musiccatalogue.api-1.8.0.0 +WORKDIR /opt/musiccatalogue.api-1.8.0.0/bin ENTRYPOINT [ "./MusicCatalogue.Api" ] diff --git a/src/MusicCatalogue.Api/Controllers/AlbumsController.cs b/src/MusicCatalogue.Api/Controllers/AlbumsController.cs index 28c3d3b..7e6cba8 100644 --- a/src/MusicCatalogue.Api/Controllers/AlbumsController.cs +++ b/src/MusicCatalogue.Api/Controllers/AlbumsController.cs @@ -45,5 +45,21 @@ public async Task>> GetAlbumsByArtistAsync(int a return albums; } + + [HttpDelete] + [Route("{id}")] + public async Task DeleteAlbum(int id) + { + // Check the album exists, first + var album = await _factory.Albums.GetAsync(x => x.Id == id); + if (album == null) + { + return NotFound(); + } + + // It does, so delete it + await _factory.Albums.DeleteAsync(id); + return Ok(); + } } } diff --git a/src/MusicCatalogue.Api/MusicCatalogue.Api.csproj b/src/MusicCatalogue.Api/MusicCatalogue.Api.csproj index 638532d..e95904c 100644 --- a/src/MusicCatalogue.Api/MusicCatalogue.Api.csproj +++ b/src/MusicCatalogue.Api/MusicCatalogue.Api.csproj @@ -2,9 +2,9 @@ net7.0 - 1.7.0.0 - 1.7.0.0 - 1.7.0 + 1.8.0.0 + 1.8.0.0 + 1.8.0 enable enable