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
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Threading.Tasks; | |
using Microsoft.AspNetCore.Mvc; | |
using Microsoft.Extensions.Logging; | |
using Swashbuckle.AspNetCore.Annotations; | |
using VND.CoolStore.Services.ApiGateway.Infrastructure.Service; | |
using VND.CoolStore.Services.ApiGateway.Model; | |
using VND.CoolStore.Shared.Catalog.GetProductById; |
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 sealed class Cart : AggregateRootBase | |
{ | |
private Cart() : base(GenerateId()) | |
{ | |
} | |
private Cart(Guid id) : base(id) | |
{ | |
} |
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 sealed class CartItem : EntityBase | |
{ | |
private CartItem() : base(GenerateId()) | |
{ | |
} | |
private CartItem(Guid id, int quantity, double price = 0.0D, double promoSavings = 0.0D) : base(id) | |
{ | |
Quantity = quantity; | |
Price = price; |
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 sealed class Product : IdentityBase | |
{ | |
private Product() : base() | |
{ | |
} | |
private Product(Guid productId) | |
: this(productId, string.Empty, 0.0D, string.Empty) | |
{ | |
} |
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 RequestHandler : RequestHandlerBase<GetCartRequest, GetCartResponse> | |
{ | |
private readonly ICatalogGateway _catalogGateway; | |
private readonly IShippingGateway _shippingGateway; | |
private readonly IPromoGateway _promoGateway; | |
public RequestHandler(ICatalogGateway cgw, IQueryRepositoryFactory qrf, | |
IShippingGateway shippingGateway, IPromoGateway promoGateway) | |
: base(qrf) | |
{ |
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 RequestHandler : TxRequestHandlerBase<InsertItemToNewCartRequest, InsertItemToNewCartResponse> | |
{ | |
private readonly ICatalogGateway _catalogGateway; | |
private readonly IShippingGateway _shippingGateway; | |
private readonly IPromoGateway _promoGateway; | |
public RequestHandler( | |
IUnitOfWorkAsync uow, IQueryRepositoryFactory qrf, | |
ICatalogGateway catalogGateway, IShippingGateway shippingGateway, | |
IPromoGateway promoGateway) : base(uow, qrf) |
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 RequestHandler : TxRequestHandlerBase<UpdateItemInCartRequest, UpdateItemInCartResponse> | |
{ | |
private readonly ICatalogGateway _catalogGateway; | |
private readonly IShippingGateway _shippingGateway; | |
private readonly IPromoGateway _promoGateway; | |
public RequestHandler(IUnitOfWorkAsync uow, IQueryRepositoryFactory qrf, | |
ICatalogGateway catalogGateway, IShippingGateway shippingGateway, | |
IPromoGateway promoGateway) : base(uow, qrf) | |
{ |
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 RequestHandler : TxRequestHandlerBase<DeleteItemRequest, DeleteItemResponse> | |
{ | |
private readonly ICatalogGateway _catalogGateway; | |
private readonly IShippingGateway _shippingGateway; | |
private readonly IPromoGateway _promoGateway; | |
public RequestHandler(IUnitOfWorkAsync uow, IQueryRepositoryFactory qf, | |
ICatalogGateway cgw, IShippingGateway shippingGateway, IPromoGateway promoGateway) | |
: base(uow, qf) | |
{ |
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 RequestHandler : TxRequestHandlerBase<CheckoutRequest, CheckoutResponse> | |
{ | |
public RequestHandler(IUnitOfWorkAsync uow, IQueryRepositoryFactory qrf) | |
: base(uow, qrf) | |
{ | |
} | |
public override async Task<CheckoutResponse> Handle(CheckoutRequest request, CancellationToken cancellationToken) | |
{ | |
var cartCommander = UnitOfWork.Repository<Domain.Cart>(); |
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
[ApiController] | |
[ApiVersion("1.0")] | |
[Route("api/carts")] | |
public class CartController : Controller | |
{ | |
[HttpGet] | |
[Route("{id}")] | |
[Auth(Policy = "access_cart_api")] | |
public async Task<IActionResult> Get([FromServices] IMediator eventor, Guid id, CancellationToken cancellationToken) | |
{ |