Beispiel #1
0
        /// <summary>
        /// I tried to build it in a way that much could be
        /// reused for the order by piece.  We didn't have
        /// the name uniform prints yet.  All of that can and
        /// should be refactored.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void placeOrderStandard_Click(object sender, EventArgs e)
        {
            //Get elements from form
            PhotoLineItem lineItem = new PhotoLineItem((PhotoTypeChoices)photoTypeStandard.SelectedIndex, (int)qtyStandard.Value,
                                                       (FinishTypeChoices)finishStandard.SelectedIndex);
            DeliveryTypeChoices deliveryChoice = (DeliveryTypeChoices)deliveryTypeStandard.SelectedIndex;

            //Get Line Rate, discounts and fees
            LineRatesStandard rate = new LineRatesStandard(lineItem);

            lineItem.LineRate = rate.getLineRate();

            PromoDiscount promoDiscount = new PromoDiscount();

            promoDiscount.CalculateDiscount(lineItem, promoCodeTxt.Text);

            DeliveryRateFee deliveryFee = new DeliveryRateFee();

            deliveryFee.setFee(new List <PhotoLineItem> {
                lineItem
            }, deliveryChoice, OrderType.standard);

            //build the order
            Order order = new Order(lineItem, promoDiscount, deliveryFee);

            MessageBox.Show(Receipt.buildReceipt(order));



            //Calculate Total


//            MessageBox.Show("BaseRate: " + rate.getBaseRate() + "\nDeliveryUpcharge: " + rate.getDeliveryRateUpcharge() +
//                "\nFinishUpcarge: " + rate.getFinishTypeUpcharge());
        }
        public void setFee(List <PhotoLineItem> lines, DeliveryTypeChoices deliveryType, OrderType orderType)
        {
            if (deliveryType == DeliveryTypeChoices.nextDay)
            {
                amount = 0;
                return;
            }

            int quanity = 0;

            foreach (var line in lines)
            {
                quanity += line.Quantity;
            }
            if (orderType == OrderType.standard)
            {
                amount = (quanity <= 60) ? 1M : 1.5M;
            }
            else
            {
                amount = (quanity <= 60) ? 2M : 2.5M;
            }
        }