Skip to content

Commit

Permalink
Merge pull request #15 from davewalker5/MC-103-Purchase-Details
Browse files Browse the repository at this point in the history
MC-103 Purchase Details
  • Loading branch information
davewalker5 authored Nov 12, 2023
2 parents b21d803 + 947bc9d commit 14bd7b0
Show file tree
Hide file tree
Showing 86 changed files with 1,921 additions and 532 deletions.
16 changes: 13 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@
- The following is an example, illustrating the format for the headers and for the rows containing data:

```
Artist,Album,Genre,Released,Cover Url,Track Number,Track,Duration,Wish List
Duke Ellington,Ellington Indigoes,Jazz,1958,,1,Solitude,04:43,False
Artist,Album,Genre,Released,Cover Url,Track Number,Track,Duration,Wish List,Purchase Date,Price,Retailer
George Harrison,All Things Must Pass,Rock & Roll,1970,https://www.theaudiodb.com/images/media/album/thumb/all-things-must-pass-4f09954aa6370.jpg,1,I'd Have You Anytime,02:56,False,12/11/2023,59.07,Amazon
```

- Exports include all albums in both the main catalogue and the wish list
Expand Down Expand Up @@ -134,12 +134,16 @@ MusicCatalogue.LookupTool --lookup "John Coltrane" "Blue Train" catalogue

### Configuration

- The UI uses a simple "config.json" file containing only one setting, the base URL for the Music Catalogue web service:
- The UI uses a simple "config.json" file containing the base URL for the Music Catalogue web service and locale settings used by the UI:

```json
{
"api": {
"baseUrl": "http://localhost:8098"
},
"region": {
"locale": "en-GB",
"currency": "GBP"
}
}
```
Expand Down Expand Up @@ -167,6 +171,10 @@ MusicCatalogue.LookupTool --lookup "John Coltrane" "Blue Train" catalogue
- As the mouse pointer is moved up and down the table, the current row is highlighted
- Clicking on the trash icon prompts for confirmation and, if confirmed, deletes the album shown in that row along with the associated tracks
- Clicking on the "heart" icon moves the album from the main catalogue to the wish list then refreshes the album list
- Clicking on the "money" icon opens a form allowing the purchase details to be set:

<img src="diagrams/purchase-details.png" alt="Purchase Details" width="600">

- Clicking anywhere else on a row opens the track list for the album shown in that row:

<img src="diagrams/track-list.png" alt="Track List" width="600">
Expand All @@ -184,6 +192,7 @@ MusicCatalogue.LookupTool --lookup "John Coltrane" "Blue Train" catalogue
- Clicking on a row drills into the album content, as per the "Artists" page
- Clicking on the trash icon prompts for confirmation and, if confirmed, deletes the album shown in that row along with the associated tracks
- Clicking on the vinyl record icon moves the album from the wish list to the main catalogue then refreshes the album list
- Clicking on the money icon opens the purchase details page and allows the price and a potential retailer to be set, but not the purchase date

### Album Lookup

Expand Down Expand Up @@ -237,6 +246,7 @@ MusicCatalogue.LookupTool --lookup "John Coltrane" "Blue Train" catalogue
- Retrieving artist details from the local database
- Retrieving album and track details from the local database
- Looking up albums via the external APIs (see below)
- Managing retailers and purchase details
- The external lookup uses the "album lookup" algorithm described under "Album Lookup", below
- Swagger documentation exposed at:

Expand Down
Binary file modified diagrams/album-list.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified diagrams/artist-list.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified diagrams/database-schema.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added diagrams/purchase-details.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions docker/api/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM mcr.microsoft.com/dotnet/core/aspnet:latest
COPY musiccatalogue.api-1.9.0.0 /opt/musiccatalogue.api-1.9.0.0
WORKDIR /opt/musiccatalogue.api-1.9.0.0/bin
COPY musiccatalogue.api-1.10.0.0 /opt/musiccatalogue.api-1.10.0.0
WORKDIR /opt/musiccatalogue.api-1.10.0.0/bin
ENTRYPOINT [ "./MusicCatalogue.Api" ]
4 changes: 2 additions & 2 deletions docker/ui/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM node:20-alpine
COPY musiccatalogue.ui-1.9.0.0 /opt/musiccatalogue.ui-1.9.0.0
WORKDIR /opt/musiccatalogue.ui-1.9.0.0
COPY musiccatalogue.ui-1.10.0.0 /opt/musiccatalogue.ui-1.10.0.0
WORKDIR /opt/musiccatalogue.ui-1.10.0.0
RUN npm install
RUN npm run build
ENTRYPOINT [ "npm", "start" ]
5 changes: 4 additions & 1 deletion src/MusicCatalogue.Api/Controllers/AlbumsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,10 @@ public async Task<ActionResult<Album>> UpdateAlbumAsync([FromBody] Album templat
template.Released,
template.Genre,
template.CoverUrl,
template.IsWishListItem);
template.IsWishListItem,
template.Purchased,
template.Price,
template.RetailerId);

// If the result is NULL, the album doesn't exist
if (album == null)
Expand Down
2 changes: 1 addition & 1 deletion src/MusicCatalogue.Api/Controllers/ExportController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public ExportController(IBackgroundQueue<CatalogueExportWorkItem> catalogueQueue

[HttpPost]
[Route("catalogue")]
public IActionResult ExportSightings([FromBody] CatalogueExportWorkItem item)
public IActionResult Export([FromBody] CatalogueExportWorkItem item)
{
// Set the job name used in the job status record
item.JobName = "Catalogue Export";
Expand Down
119 changes: 119 additions & 0 deletions src/MusicCatalogue.Api/Controllers/RetailersController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using MusicCatalogue.Entities.Database;
using MusicCatalogue.Entities.Exceptions;
using MusicCatalogue.Entities.Interfaces;

namespace MusicCatalogue.Api.Controllers
{
[Authorize]
[ApiController]
[ApiConventionType(typeof(DefaultApiConventions))]
[Route("[controller]")]
public class RetailersController : Controller
{
private readonly IMusicCatalogueFactory _factory;

public RetailersController(IMusicCatalogueFactory factory)
{
_factory = factory;
}

/// <summary>
/// Return a list of all the retailers in the catalogue
/// </summary>
/// <returns></returns>
[HttpGet]
[Route("")]
public async Task<ActionResult<List<Retailer>>> GetRetailersAsync()
{
// Get a list of all artists in the catalogue
List<Retailer> retailers = await _factory.Retailers.ListAsync(x => true);

// If there are no artists, return a no content response
if (!retailers.Any())
{
return NoContent();
}

return retailers;
}

/// <summary>
/// Return retailer details given a retailer ID
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
[HttpGet]
[Route("{id:int}")]
public async Task<ActionResult<Retailer>> GetRetailerByIdAsync(int id)
{
var retailer = await _factory.Retailers.GetAsync(x => x.Id == id);

if (retailer == null)
{
return NotFound();
}

return retailer;
}

/// <summary>
/// Add a retailer to the catalogue
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
[HttpPost]
[Route("")]
public async Task<ActionResult<Retailer>> AddRetailerAsync([FromBody] Retailer template)
{
var retailer = await _factory.Retailers.AddAsync(template.Name);
return retailer;
}

/// <summary>
/// Update an existing retailer
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
[HttpPut]
[Route("")]
public async Task<ActionResult<Retailer?>> UpdateRetailerAsync([FromBody] Retailer template)
{
var retailer = await _factory.Retailers.UpdateAsync(template.Id, template.Name);
return retailer;
}

/// <summary>
/// Delete an existing retailer
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
[HttpDelete]
[Route("{id}")]
public async Task<IActionResult> DeleteRetailerAsync(int id)
{
// Make sure the retailer exists
var retailer = await _factory.Retailers.GetAsync(x => x.Id == id);

// If the retailer doesn't exist, return a 404
if (retailer == null)
{
return NotFound();
}

try
{
// Delete the retailer
await _factory.Retailers.DeleteAsync(id);
}
catch (RetailerInUseException)
{
// Retailer is in use so this is a bad request
return BadRequest();
}

return Ok();
}
}
}
6 changes: 3 additions & 3 deletions src/MusicCatalogue.Api/MusicCatalogue.Api.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<ReleaseVersion>1.9.0.0</ReleaseVersion>
<FileVersion>1.9.0.0</FileVersion>
<ProductVersion>1.9.0</ProductVersion>
<ReleaseVersion>1.10.0.0</ReleaseVersion>
<FileVersion>1.10.0.0</FileVersion>
<ProductVersion>1.10.0</ProductVersion>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
Expand Down
Loading

0 comments on commit 14bd7b0

Please sign in to comment.