public async Task <PriceCalculateVm> Handle(CalulatePriceQuery request, CancellationToken cancellationToken) { var result = new PriceCalculateVm(); var basket = _shoppingBasketService.AddProducts(request.Products); var discounts = await _productService.GetProductDiscounts(); var applyDiscount = _discountService.CalculateBasketDiscounts(basket, discounts); var subTotalPrice = basket.Sum(item => item.Product.Price * item.Quantity); var totalPrice = subTotalPrice - applyDiscount.Sum(item => item.Amount); result.PriceInfo = new PriceInfoDto() { Total = totalPrice, SubTotal = subTotalPrice, DiscontMessage = string.Join(" --- ", applyDiscount.Select(x => x.Description)) }; return(result); }