public IReadOnlyList <PricedProductItem> Calculate(params ProductItem[] productItems) { return(productItems .Select(pi => PricedProductItem.Create(pi, FakePrice)) .ToList()); }
public IReadOnlyList <PricedProductItem> Calculate(params ProductItem[] productItems) { Guard.Against.Zero(productItems.Length, "Product items count"); var random = new Random(); return(productItems .Select(pi => PricedProductItem.Create(pi, (decimal)random.NextDouble() * 100)) .ToList()); }
public IReadOnlyList <PricedProductItem> Calculate(params ProductItem[] productItems) { if (productItems.Length == 0) { throw new ArgumentOutOfRangeException(nameof(productItems.Length)); } var random = new Random(); return(productItems .Select(pi => PricedProductItem.Create(pi, (decimal)random.NextDouble() * 100)) .ToList()); }
public async Task <IActionResult> RemoveProduct(Guid id, [FromBody] RemoveProductRequest request) { var command = Carts.RemovingProduct.RemoveProduct.Create( id, PricedProductItem.Create( request?.ProductItem?.ProductId, request?.ProductItem?.Quantity, request?.ProductItem?.UnitPrice ) ); await commandBus.Send(command); return(Ok()); }
public async Task <IActionResult> InitOrder([FromBody] InitOrderRequest?request) { var orderId = idGenerator.New(); var command = InitializeOrder.Create( orderId, request?.ClientId, request?.ProductItems?.Select( pi => PricedProductItem.Create(pi.ProductId, pi.Quantity, pi.UnitPrice)).ToList(), request?.TotalPrice ); await commandBus.Send(command); return(Created("api/Orders", orderId)); }
public async Task <IActionResult> RemoveProduct(Guid id, [FromBody] RemoveProductRequest request) { Guard.Against.Null(request, nameof(request)); Guard.Against.Null(request.ProductItem, nameof(request)); var command = Commands.RemoveProduct.Create( id, PricedProductItem.Create( request.ProductItem.ProductId, request.ProductItem.Quantity, request.ProductItem.UnitPrice ) ); await commandBus.Send(command); return(Ok()); }
public async Task <IActionResult> InitOrder([FromBody] InitOrderRequest request) { Guard.Against.Null(request, nameof(request)); var orderId = idGenerator.New(); var command = Commands.InitOrder.Create( orderId, request.ClientId, request.ProductItems?.Select( pi => PricedProductItem.Create(pi.ProductId, pi.Quantity, pi.UnitPrice)).ToList(), request.TotalPrice ); await commandBus.Send(command); return(Created("api/Orders", orderId)); }