-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from davewalker5/MC-103-Purchase-Details
MC-103 Purchase Details
- Loading branch information
Showing
86 changed files
with
1,921 additions
and
532 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
119 changes: 119 additions & 0 deletions
119
src/MusicCatalogue.Api/Controllers/RetailersController.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.