private async Task NotifyCustomerOfDelay(Customer customer, Order order) { var message = string.Format("Dear {0} {1}, Your order {2} cannot be delivered - please contact customer support", customer.FirstName, customer.Surname, order.ID); await EmailClient.Send(customer.EmailAddress, "Failed delivering order", message); }
public async Task SendOrder(Customer customer, Order order) { try { var orderEta = CalculateOrderEta(order, customer.Address); await SendAsync(order, customer.Address); await NotifyCustomerOfSuccess(customer, order.ID, orderEta); } catch (IllegalOrderException exc) { await NotifyCustomerOfDelay(customer, order); throw new OrderProcessingException("Failed to deliver order " + order.ID, exc); } }
private DateTime CalculateOrderEta(Order order, Address destination) { return _shippingCalculators[order.ShippingMethod].CalculateEta(_originCountry, destination); }
private async Task SendAsync(Order order, Address address) { await Task.FromResult(false); }