/// <summary> /// Sends an email to welcome a new vendor. /// </summary> /// <returns></returns> public string SendWelcomeEmail(string message) { var emailService = new EmailService(); var subject = "Hello" + this.CompanyName; var confirmation = emailService.SendMessage(subject, message, this.Email); return confirmation; }
public string SayHello() { //var vendor = new Vendor(); //vendor.SendWelcomeEmail("Message from Product"); var emailService = new EmailService(); var confirmation = emailService.SendMessage("New Product", this.ProductName, "*****@*****.**"); var result = LogAction("saying hello"); return "Hello " + ProductName + " (" + ProductId + "): " + Description; }
/// <summary> /// Sends a product order to the vendor. /// </summary> /// <param name="product">Product to order.</param> /// <param name="quantity">Quantity of the product to order.</param> /// <param name="deliverBy">Requested delivery date.</param> /// <param name="instructions">Delivery instructions.</param> /// <returns></returns> public OperationResult<bool, string> PlaceOrder(Product product, int quantity, DateTimeOffset? deliverBy = null, string instructions = "standard delivery") { if (product == null) throw new ArgumentNullException(nameof(product)); if (quantity <= 0) throw new ArgumentOutOfRangeException(nameof(quantity)); if (deliverBy <= DateTimeOffset.Now) throw new ArgumentOutOfRangeException(nameof(deliverBy)); var success = false; var orderTextBuilder = new StringBuilder("Order from Acme, Inc" + System.Environment.NewLine + "Product: " + product.ProductName + System.Environment.NewLine + "Quantity: " + quantity); if (deliverBy.HasValue) { orderTextBuilder.Append( System.Environment.NewLine + "Deliver By: " + deliverBy.Value.ToString("d")); } if (!String.IsNullOrWhiteSpace(instructions)) { orderTextBuilder.Append( System.Environment.NewLine + "Instructions: " + instructions); } var orderText = orderTextBuilder.ToString(); var emailService = new EmailService(); var confirmation = emailService.SendMessage("New Order", orderText, this.Email); if (confirmation.StartsWith("Message sent:")) { success = true; } var operationResult = new OperationResult<bool,string>(success, orderText); return operationResult; }
/// <summary> /// Sends a product order to the vendor /// </summary> /// <param name="product">Product to order</param> /// <param name="quantity">Quantity of the product to order.</param> /// <returns></returns> public OperationResult PlaceOrder(Product product, int quantity, DateTimeOffset? deliverBy, string instructions) { if (product == null) throw new ArgumentNullException("product"); if (quantity < 0) throw new ArgumentNullException("quantity"); if (deliverBy <= DateTimeOffset.Now) throw new ArgumentOutOfRangeException("deliverBy"); var success = false; var orderText = "Order from Acme, Inc" + System.Environment.NewLine + "Product: " + product.ProductName + System.Environment.NewLine + "Quantity: " + quantity; if (deliverBy.HasValue) { orderText += System.Environment.NewLine + "Deliver By: " + deliverBy.Value.ToString("d"); } if (!string.IsNullOrWhiteSpace(instructions)) { orderText += System.Environment.NewLine + "Instuctions: " + instructions; } var emailService = new EmailService(); var confirmation = emailService.SendMessage("New Order", orderText, this.Email); if (confirmation.StartsWith("Message sent:")) { success = true; } var operationResult = new OperationResult(success, orderText); return operationResult; }
Cost + (Cost * markupPercent / 100); // expression-bodied method syntax public string SayHello() { //var vendor = new Vendor(); //vendor.SendWelcomeEmail("Message from the vendor!"); var emailService = new EmailService(); var confirmation = emailService.SendMessage("New Product", this.ProductName, "*****@*****.**"); var result = LogAction("Saying Hello"); // using static Acme.Common.LoggingService; return "Hello " + ProductName + " (" + ProductId + "): " + Description + " Available on: " + AvailabilityDate?.ToShortDateString(); }
public string SayHello() { var vendor = new Vendor(); vendor.SendWelcomeEmail("Message from Product"); var emailService = new EmailService(); emailService.SendMessage("New Product", this.ProductName, "*****@*****.**"); var result = LogAction("Product SayHello"); return "Hello " + ProductName + " (" + ProductId + "): " + Description + " Available on: " + AvailabilityDate?.ToShortDateString(); }
/// <summary> /// Sends a product order to the vendor. /// </summary> /// <param name="product">Product to order.</param> /// <param name="quantity">Quantity of the product to order.</param> /// <param name="deliverBy">Requested delivery date.</param> /// <param name="instructions">Delivery instructions</param> /// <returns></returns> public OperationResult PlaceOrder(Product product, int quantity, DateTimeOffset? deliverBy = null, string instructions = "standard delivery") { // Guard clauses make sure passed in values are within constraints. if (product == null) throw new ArgumentNullException(nameof(product)); if (quantity <= 0) throw new ArgumentOutOfRangeException(nameof(product)); if (deliverBy <= DateTimeOffset.Now) throw new ArgumentOutOfRangeException(nameof(deliverBy)); var success = false; var orderText = "Order from ACME, Inc" + "\n" + "Product: " + product.ProductCode + "\n" + "Quantity: " + quantity; if (deliverBy.HasValue) { orderText += "\n" + "Deliver By: " + deliverBy.Value.ToString("d"); } if (!String.IsNullOrWhiteSpace(instructions)) { orderText += "\n" + "Instructions: " + instructions; } var emailService = new EmailService(); var confirmation = emailService.SendMessage("New Order", orderText, Email); if (confirmation.StartsWith("Message sent: ")) { success = true; } var operationResult = new OperationResult(success, orderText); return operationResult; }
public static List<string> SendEmail(ICollection<Vendor> vendors, string message) { var confirmations = new List<string>(); var emailService = new EmailService(); Console.WriteLine(vendors.Count); foreach (var vendor in vendors) { var subject = "Important message for: " + vendor.CompanyName; var confirmation = emailService.SendMessage(subject, message, vendor.Email); confirmations.Add(confirmation); } return confirmations; }
/// <summary> /// Send Order to Vendor /// </summary> /// <param name="product">Product Ordered</param> /// <param name="quantity">Product Quantity</param> /// <param name="deliveryBy">Requested Delivery Date.</param> /// <param name="instruction">Delivery Instruction</param> /// <returns>True or false</returns> public OperationResult PlaceOrder(Product product, int quantity, DateTimeOffset? deliveryBy=null,string instruction="Standard Delivery") { if (product == null) { throw new ArgumentNullException(nameof(product)); } if (quantity <= 0) { throw new ArgumentOutOfRangeException(nameof(quantity)); } var success = false; var orderText = "Order from Acme, Inc" + System.Environment.NewLine + "Product: " + product.ProductCode + System.Environment.NewLine + "Quantity: " + quantity; if (deliveryBy!=null && deliveryBy.HasValue) { orderText += Environment.NewLine + "Deliver By: " + deliveryBy.Value.ToString("d"); } if (!String.IsNullOrWhiteSpace(instruction)) { orderText += Environment.NewLine + "Instructions: " +instruction; } var emailService = new EmailService(); var confirmation = emailService.SendMessage("New Order", orderText, this.Email); if (confirmation.StartsWith("Message sent:", StringComparison.CurrentCultureIgnoreCase)) { success = true; } var operationResult = new OperationResult(success, orderText); return operationResult; }