Ejemplo n.º 1
0
 private void SendGift(Customer customer)
 {
     if (customer.Address.City == "Chicago")
     {
         SendThankYouLetterInternal(customer.EmailAddress);
     }
 }
Ejemplo n.º 2
0
        private async Task NotifyCustomerOfSuccess(Customer customer, int orderId, DateTime orderEta)
        {
            var message = string.Format("Dear {0} {1}, Your order {2} has been shipped and expected to arrive at: {3}",
                customer.FirstName, customer.Surname, orderId, orderEta);

            await EmailClient.Send(customer.EmailAddress, "Order sent", message);
        }
Ejemplo n.º 3
0
        private async Task NotifyCustomerOfDelay(Customer customer, Order order)
        {
            var message =
                string.Format("Dear {0} {1}, Your order {2} cannot be delivered - please contact customer support",
                    customer.FirstName, customer.Surname, order.ID);

            await EmailClient.Send(customer.EmailAddress, "Failed delivering order", message);
        }
Ejemplo n.º 4
0
        private void SendOverseasPackage(Customer customer)
        {
            if (customer.Address.Country == "US")
            {
                // Shouldn't get here
                Debugger.Break();
            }

            // Send package
        }
Ejemplo n.º 5
0
 private void SendThankYouLetter(Customer customer)
 {
     if (customer.EmailAddress.Length > MaxEmailLength)
     {
         SendThankYouLetterInternal(customer.EmailAddress);
     }
     else
     {
         Debug.Write("Email address too long!");
     }
 }
Ejemplo n.º 6
0
        private static double CalculateExpenses(Customer customer)
        {
            Debugger.Break();

            int retailerGiftPrice = IsElgibileForDiscount(customer) ? GetDiscountPrice() : GetRegularPrice();

            int shippingCost;
            if (int.TryParse(GetShippingCostFromConfig(), out shippingCost))
            {
                retailerGiftPrice += shippingCost;
            }

            AddVAT(ref retailerGiftPrice);

            return retailerGiftPrice + GetExtraFreebiesCost(customer);
        }
Ejemplo n.º 7
0
        public async Task SendOrder(Customer customer, Order order)
        {
            try
            {
                var orderEta = CalculateOrderEta(order, customer.Address);

                await SendAsync(order, customer.Address);

                await NotifyCustomerOfSuccess(customer, order.ID, orderEta);

            }
            catch (IllegalOrderException exc)
            {
                await NotifyCustomerOfDelay(customer, order);

                throw new OrderProcessingException("Failed to deliver order " + order.ID, exc);
            }
        }
Ejemplo n.º 8
0
        public int DaysTillBirthday(Customer customer, DateTime today)
        {
            try
            {
                var birthday = customer.Birthday;

                DateTime next = new DateTime(today.Year, birthday.Month, birthday.Day);

                if (next < today)
                    next = next.AddYears(1);

                return (next - today).Days;
            }
            catch (Exception)
            {
                return int.MaxValue;
            }
        }
Ejemplo n.º 9
0
 private static bool IsElgibileForDiscount(Customer customer)
 {
     return customer.Birthday.Month > 6;
 }
Ejemplo n.º 10
0
 private static double GetExtraFreebiesCost(Customer customer)
 {
     return customer.GetYearlyEarnings(100) + 52;
 }
Ejemplo n.º 11
0
 // <---- Use QuickAction Here.
 public void SendInvoice(Customer customer)
 {
     _queue.Add(new Tuple<string, int>(customer.EmailAddress, customer.PendingInvoiceID));
 }
Ejemplo n.º 12
0
        private static int SendGift(Customer customer)
        {
            int retailerGiftPrice = IsElgibileForDiscount(SupplierId) ? GetDiscountPrice() : GetRegularPrice();

            int shippingCost;
            if (int.TryParse(GetShippingCostFromConfig(), out shippingCost))
            {
                retailerGiftPrice += shippingCost;
            }

            AddVAT(ref retailerGiftPrice);

            return retailerGiftPrice + GetExtraFreebiesCost(customer);
        }
Ejemplo n.º 13
0
 private static bool IsEligibleForPrize(Customer customer)
 {
     return customer.Gender == Gender.Female;
 }
Ejemplo n.º 14
0
 private static int GetExtraFreebiesCost(Customer customer)
 {
     return 52;
 }