コード例 #1
0
        public async Task ProcessPurchases()
        {
            try
            {
                _logHandler.LogInfo("Looking for purchases...");
                var purchases = await _repo.GetData();

                if (!purchases.List.Any())
                {
                    _logHandler.LogInfo("No purchases found!");
                    return;
                }
                else
                {
                    _logHandler.LogInfo("Purchases found!");
                }


                var generatedReceipts = new List <IReceipt>();
                foreach (var purchase in purchases.List)
                {
                    var receipt = await _calculator.Compute(purchase);

                    generatedReceipts.Add(receipt);
                }
                await _notifier.Notify(new ReceiptContainer(generatedReceipts));
            }
            catch (Exception e)
            {
                _logHandler.LogError(e.Message);
            }
        }
コード例 #2
0
        public async Task Notify(ReceiptContainer receipts)
        {
            var message = _messageGenerator.Generate(receipts);

            _logHandler.LogInfo(message);
            _ = _command.Launch(message);
        }