示例#1
0
 private void SendGift(Customer customer)
 {
     if (customer.Address.City == "Chicago")
     {
         SendThankYouLetterInternal(customer.EmailAddress);
     }
 }
示例#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);
        }
示例#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);
        }
示例#4
0
        private void SendOverseasPackage(Customer customer)
        {
            if (customer.Address.Country == "US")
            {
                // Shouldn't get here
                Debugger.Break();
            }

            // Send package
        }
示例#5
0
 private void SendThankYouLetter(Customer customer)
 {
     if (customer.EmailAddress.Length > MaxEmailLength)
     {
         SendThankYouLetterInternal(customer.EmailAddress);
     }
     else
     {
         Debug.Write("Email address too long!");
     }
 }
示例#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);
        }
示例#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);
            }
        }
        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;
            }
        }
示例#9
0
 private static bool IsElgibileForDiscount(Customer customer)
 {
     return customer.Birthday.Month > 6;
 }
示例#10
0
 private static double GetExtraFreebiesCost(Customer customer)
 {
     return customer.GetYearlyEarnings(100) + 52;
 }
示例#11
0
 // <---- Use QuickAction Here.
 public void SendInvoice(Customer customer)
 {
     _queue.Add(new Tuple<string, int>(customer.EmailAddress, customer.PendingInvoiceID));
 }
        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);
        }
 private static bool IsEligibleForPrize(Customer customer)
 {
     return customer.Gender == Gender.Female;
 }
 private static int GetExtraFreebiesCost(Customer customer)
 {
     return 52;
 }