Example #1
0
        public async Task SaveReportAsync()
        {
            IReadOnlyCollection <Cart> carts = await _cartService.GetAllAsync();

            IReadOnlyCollection <CartItem> cartItems = await _cartItemService.GetAllAsync();

            IReadOnlyCollection <Product> products = await _productService.GetAllAsync();

            var sb = new StringBuilder();

            WriteTotalCarts(carts, sb);
            WriteCartsWithBonus(sb, carts, cartItems, products);
            WriteCartsToExpire(sb, carts);
            WriteCartsCostAverage(sb, carts, cartItems, products);

            var reportText = sb.ToString();

            await SaveReportToFileAsync(reportText);
        }