Browse Source

Apply suggestions from code review

Co-authored-by: David Pine <david.pine@microsoft.com>
pull/1770/head
Sumit Ghosh 3 years ago
committed by GitHub
parent
commit
3a0f094d53
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 11 additions and 10 deletions
  1. +1
    -1
      src/ApiGateways/Mobile.Bff.Shopping/aggregator/Controllers/HomeController.cs
  2. +1
    -1
      src/ApiGateways/Mobile.Bff.Shopping/aggregator/Models/BasketData.cs
  3. +1
    -1
      src/ApiGateways/Mobile.Bff.Shopping/aggregator/Models/OrderData.cs
  4. +1
    -1
      src/ApiGateways/Mobile.Bff.Shopping/aggregator/Program.cs
  5. +1
    -1
      src/ApiGateways/Mobile.Bff.Shopping/aggregator/Services/IBasketService.cs
  6. +2
    -2
      src/ApiGateways/Web.Bff.Shopping/aggregator/Controllers/BasketController.cs
  7. +1
    -1
      src/ApiGateways/Web.Bff.Shopping/aggregator/Controllers/HomeController.cs
  8. +3
    -2
      src/ApiGateways/Web.Bff.Shopping/aggregator/Controllers/OrderController.cs

+ 1
- 1
src/ApiGateways/Mobile.Bff.Shopping/aggregator/Controllers/HomeController.cs View File

@ -3,7 +3,7 @@
[Route("")]
public class HomeController : Controller
{
[HttpGet()]
[HttpGet]
public IActionResult Index()
{
return new RedirectResult("~/swagger");


+ 1
- 1
src/ApiGateways/Mobile.Bff.Shopping/aggregator/Models/BasketData.cs View File

@ -4,7 +4,7 @@ public class BasketData
{
public string BuyerId { get; set; }
public List<BasketDataItem> Items { get; set; } = new List<BasketDataItem>();
public List<BasketDataItem> Items { get; set; } = new();
public BasketData()
{


+ 1
- 1
src/ApiGateways/Mobile.Bff.Shopping/aggregator/Models/OrderData.cs View File

@ -38,5 +38,5 @@ public class OrderData
public string Buyer { get; set; }
public List<OrderItemData> OrderItems { get; } = new List<OrderItemData>();
public List<OrderItemData> OrderItems { get; } = new();
}

+ 1
- 1
src/ApiGateways/Mobile.Bff.Shopping/aggregator/Program.cs View File

@ -1,4 +1,4 @@
BuildWebHost(args).Run();
await BuildWebHost(args).RunAsync();
IWebHost BuildWebHost(string[] args) =>
WebHost
.CreateDefaultBuilder(args)


+ 1
- 1
src/ApiGateways/Mobile.Bff.Shopping/aggregator/Services/IBasketService.cs View File

@ -2,7 +2,7 @@
public interface IBasketService
{
Task<BasketData> GetById(string id);
Task<BasketData> GetByIdAsync(string id);
Task UpdateAsync(BasketData currentBasket);


+ 2
- 2
src/ApiGateways/Web.Bff.Shopping/aggregator/Controllers/BasketController.cs View File

@ -26,7 +26,7 @@ public class BasketController : ControllerBase
}
// Retrieve the current basket
var basket = await _basket.GetById(data.BuyerId) ?? new BasketData(data.BuyerId);
var basket = await _basket.GetByIdAsync(data.BuyerId) ?? new BasketData(data.BuyerId);
var catalogItems = await _catalog.GetCatalogItemsAsync(data.Items.Select(x => x.ProductId));
// group by product id to avoid duplicates
@ -84,7 +84,7 @@ public class BasketController : ControllerBase
}
// Retrieve the current basket
var currentBasket = await _basket.GetById(data.BasketId);
var currentBasket = await _basket.GetByIdAsync(data.BasketId);
if (currentBasket == null)
{
return BadRequest($"Basket with id {data.BasketId} not found.");


+ 1
- 1
src/ApiGateways/Web.Bff.Shopping/aggregator/Controllers/HomeController.cs View File

@ -3,7 +3,7 @@
[Route("")]
public class HomeController : Controller
{
[HttpGet()]
[HttpGet]
public IActionResult Index()
{
return new RedirectResult("~/swagger");


+ 3
- 2
src/ApiGateways/Web.Bff.Shopping/aggregator/Controllers/OrderController.cs View File

@ -7,6 +7,7 @@ public class OrderController : ControllerBase
{
private readonly IBasketService _basketService;
private readonly IOrderingService _orderingService;
public OrderController(IBasketService basketService, IOrderingService orderingService)
{
_basketService = basketService;
@ -19,12 +20,12 @@ public class OrderController : ControllerBase
[ProducesResponseType(typeof(OrderData), (int)HttpStatusCode.OK)]
public async Task<ActionResult<OrderData>> GetOrderDraftAsync(string basketId)
{
if (string.IsNullOrEmpty(basketId))
if (string.IsNullOrWhitespace(basketId))
{
return BadRequest("Need a valid basketid");
}
// Get the basket data and build a order draft based on it
var basket = await _basketService.GetById(basketId);
var basket = await _basketService.GetByIdAsync(basketId);
if (basket == null)
{


Loading…
Cancel
Save