public IEnumerable <Customer> GetCustomersWhoWantToGetAnEmailAboutVehicle(NewVehicleAddedMessage message, int price, string currencyCode)
        {
            yield return(new Customer {
                Name = "Alice Andrews", Email = "*****@*****.**"
            });

            yield return(new Customer {
                Name = "Bob Brisket", Email = "*****@*****.**"
            });
        }
 public async void PublishNewVehicleMessage(Vehicle vehicle)
 {
     var vehicleMessage = new NewVehicleAddedMessage {
         Registration = vehicle.Registration,
         Color        = vehicle.Color,
         Year         = vehicle.Year.Value,
         Manufacturer = vehicle.VehicleModel.Manufacturer.Name,
         Model        = vehicle.VehicleModel.Name
     };
     var message = new ServiceBusMessage(JsonConvert.SerializeObject(vehicleMessage));
     await sender.SendMessageAsync(message);
 }
Exemplo n.º 3
0
        private static void SendCustomerEmails(NewVehicleAddedMessage message, PriceReply reply)
        {
            var customers = customerDatabase.GetCustomersWhoWantToGetAnEmailAboutVehicle(message, reply.Price, reply.CurrencyCode);
            var subject   = $"NEW CAR! {message.Manufacturer} {message.Model} ({message.Color}, {message.Year})";

            foreach (var customer in customers)
            {
                var body = $@"
Dear {customer.Name},

There's a new car!

It's a {message.Manufacturer} {message.Model} ({message.Color}, {message.Year})

It costs {reply.CurrencyCode} {reply.Price}

Thanks,

Autobarn";
                SendEmail(customer.Email, subject, body);
            }
        }