public void ConfirmOrder(Order order) { if (order.Status != OrderStatus.Draft) { throw new InvalidOperationException("Only draft orders can be confirmed"); } order.Status = OrderStatus.ReadyToShip; var smtpClient = new SmtpClient(); // these emails would be much longer in practice and probably not hard coded! var confirmationEmail = new MailMessage( "*****@*****.**", order.Customer.Email, "Order confirmation: " + order.Code, "Hello there, Your order is confirmed and has gone off for processing"); smtpClient.Send(confirmationEmail); var shipmentRequestEmail = new MailMessage( "*****@*****.**", OrderFulfilmentEmailAddress, "Order shipment request: " + order.Code, "Hello there, this order is confirmed. Please arrange shipment."); smtpClient.Send(shipmentRequestEmail); // maybe save order here as this would be typical procedural style (i.e. no persistence ignorance) }
public void ConfirmOrder(Order order) { var customerMessage = orderConfirmationEmailBuilder.BuildOrderConfirmationEmail(order); mailSender.SendMail(customerMessage); order.FlagAsReadyToShip(); }
public void ConfirmOrder(Order order) { order.Confirm(); var mailMessage = orderConfirmationEmailBuilder.BuildOrderConfirmationEmail(order); mailSender.SendMail(mailMessage); }
public virtual MailMessage BuildOrderConfirmationEmail(Order order) { if (order == null) throw new ArgumentNullException("order"); return new MailMessage( "*****@*****.**", order.Customer.Email, "Order confirmation: " + order.Code, "Order Confirmed"); }
public virtual MailMessage BuildOrderFulfillmentRequestEmailBuilder(Order order) { if (order == null) throw new ArgumentNullException("order"); return new MailMessage( "*****@*****.**", OrderFulfilmentEmailAddress, "Order shipment request: " + order.Code, "Hello there, this order is confirmed. Please arrange shipment."); }
public void order_confirmer() { // Arrange order = OrderTestDataFactory.GetDraftOrder(); // we still use a fake mail sender--don't want emails sent! mailSenderFake = new MailSenderFake(); // we use the real order confirmation email builder rather than mocking it out // also we don't have separate tests on the mail builder (if vertical slice approach) orderConfirmer = new OrderConfirmer(mailSenderFake, new OrderConfirmationEmailBuilder(new TemplateEmailBuilder())); }
public virtual MailMessage BuildOrderConfirmationEmail(Order order) { if (order == null) throw new ArgumentNullException("order"); var tokens = new Dictionary<string, string> { {"customer-full-name", order.Customer.FirstName + order.Customer.LastName}, {"ordernumber", order.Code} }; var mailMessage = templateEmailBuilder.BuildEmail("orderconfirmation", tokens); mailMessage.To.Add(order.Customer.Email); mailMessage.Subject = "Order confirmed: " + order.Code; return mailMessage; }
private void EnsureOrder() { if (order == null) { if (customer == null) { // todo; make a customer builder customer = new Customer("Alan", "Christensen", "*****@*****.**"); } if (string.IsNullOrWhiteSpace(code)) { code = Randomizer.RandomString(); } order = new Order(customer, code); } }
public bool Equals(Order other) { if (ReferenceEquals(null, other)) return false; if (ReferenceEquals(this, other)) return true; return Equals(other.Code, Code); }
public virtual void Enqueue(Order order) { var mailMessage = emailBuilder.BuildOrderFulfillmentRequestEmailBuilder(order); mailSender.SendMail(mailMessage); }