From 8700dce1b6d9454469ac7826c73c9c1b77627fc5 Mon Sep 17 00:00:00 2001 From: qbunia Date: Mon, 20 Feb 2023 22:22:51 +0100 Subject: [PATCH] Update EmailSender.cs --- src/Codecool.CodecoolShop/Email/EmailSender.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Codecool.CodecoolShop/Email/EmailSender.cs b/src/Codecool.CodecoolShop/Email/EmailSender.cs index 27c9fa9..3ae0fd9 100644 --- a/src/Codecool.CodecoolShop/Email/EmailSender.cs +++ b/src/Codecool.CodecoolShop/Email/EmailSender.cs @@ -6,7 +6,7 @@ internal static class Email { - public static void SendEmail(Order order, List products) + public static void SendEmail(Order order, List products) //Lista pozwala na modyfikacje kolekcji, nie chcemy jej modyfikowac dlatego nie powinno sie przekazywac tego jako lista, jak juz to arrayem { var emailTo = order.Address.Email; var client = new SmtpClient("smtp.gmail.com", 587) @@ -16,7 +16,7 @@ public static void SendEmail(Order order, List products) }; var message = CreateMessage(order, products); client.Send("codecoolshop123@gmail.com", emailTo, - $"CodeCool Shop - You buy {products.Sum(p => p.Quantity)} products", message); + $"CodeCool Shop - You buy {products.Sum(p => p.Quantity)} products", message); //jezeli products bedzie pusty to Sum wywali Ci bledem } private static string CreateMessage(Order order, List products) @@ -24,7 +24,7 @@ private static string CreateMessage(Order order, List products) var message = $"Hello {order.Address.FullName},\nHere is you confirmation order.\nYou buy:\n\n"; foreach (var product in products) message += - $"Name: {product.Name}\nPrice: {product.Price}\nQuantity: {product.Quantity}\n\n"; + $"Name: {product.Name}\nPrice: {product.Price}\nQuantity: {product.Quantity}\n\n"; //daj jakies klamerki bo to strasznie wyglada ciezko sie czyta czy ten kod nadal jest w foreachu czy nie message += $"Total price: {products.Sum(p => p.Quantity * p.Price)}\nTotal products: {products.Sum(p => p.Quantity)}\n\n"; @@ -33,4 +33,4 @@ private static string CreateMessage(Order order, List products) $"Country: {order.Address.Country}\nEmail: {order.Address.Email}\nPhone: {order.Address.Phone}\n"; return message; } -} \ No newline at end of file +}