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
public class Basket | |
{ | |
public string Id { get; set; } = Guid.NewGuid().ToString(); | |
public string CustomerId { get; set; } | |
public double TotalAmount { get; set; } | |
public List<BasketItem> Items { get; set; } | |
} |
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
public interface IBasketRepository | |
{ | |
Task<Basket> GetCustomerBasketAsync(string customerId); | |
Task<Basket> UpdateBasketAsync(Basket basket); | |
Task<bool> DeleteBasketAsync(string id); | |
Task<bool> RemoveItemFromBasket(string customerId, string itemId); | |
} |
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
[Route("api/[controller]")] | |
[ApiController] | |
public class BasketController : ControllerBase | |
{ | |
private readonly IBasketRepository _basketRepository; | |
public BasketController(IBasketRepository basketRepository) | |
{ | |
_basketRepository = basketRepository; | |
} |