Exemplo n.º 1
0
        public override void Generate(ShoppingCart cart, CustomerInfo customer)
        {
            string confirmationHeader = "Customer email, order confirmation:";
            string confirmationData   = "";
            string downloadHeader     = $"{Environment.NewLine}Customer download links and license keys";
            string downloadData       = "";


            foreach (CartItem item in cart.items)
            {
                if (item.product.GetType().Equals(typeof(PhysicalProduct)))
                {
                    PhysicalProduct product = item.product as PhysicalProduct;
                    confirmationData += $"{Environment.NewLine}name: {product.title}, description: {product.description}, price: {product.price}, quantity: {item.quantity}";
                }

                if (item.product.GetType().Equals(typeof(DigitalProduct)))
                {
                    DigitalProduct product = item.product as DigitalProduct;
                    confirmationData += $"{Environment.NewLine}name: {product.title}, description: {product.description}, price: {product.price}, quantity: {item.quantity}";
                    downloadData     += $"{Environment.NewLine}name: {product.title}, license key: {product.licenseKey}, download: {product.downloadLink}, downloads available: {item.quantity}";
                }
            }

            string finalDownloadData = (downloadHeader == "") ? "" : downloadHeader + downloadData;
            string finalData         = confirmationHeader + confirmationData + finalDownloadData;

            this.Send(finalData, customer.email);
        }
Exemplo n.º 2
0
        public override void Generate(ShoppingCart cart, CustomerInfo customer)
        {
            string emailHeader = $"Company email for shipping:{Environment.NewLine}Mail to: {customer.city}, {customer.street}, {customer.zipcode}";
            string emailData   = "";

            foreach (CartItem item in cart.items)
            {
                if (item.product.GetType().Equals(typeof(PhysicalProduct)))
                {
                    PhysicalProduct product = item.product as PhysicalProduct;
                    emailData += $"{Environment.NewLine}name: {product.title}, description: {product.description}, price: {product.price}, quantity: {item.quantity}{Environment.NewLine}length: {product.size.Item1}, width: {product.size.Item2}, height: {product.size.Item3}{Environment.NewLine}weight: {product.weight} kg";
                }
            }

            string finalData = emailHeader + emailData;

            this.Send(finalData, companyEmail);
        }