Example #1
0
        private Order createOrder(int userID)
        {
            Order order = new Order();

            order.Date      = DateTime.Now.ToUniversalTime();
            order.Firstname = txtFirstname.Text;
            order.Lastname  = txtLastname.Text;
            order.Address   = txtAddress.Text;
            order.City      = txtCity.Text;
            order.Phone     = txtPhone.Text;
            order.Email     = txtEmail.Text;
            order.Items     = getItems();
            order.User      = new User(userID, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, null, string.Empty, string.Empty, DateTime.Now, string.Empty, 0, 1);
            order.Name      = (rdbUserType.SelectedValue == "2") ? txtCompanyName.Text : string.Empty;
            order.Pib       = (rdbUserType.SelectedValue == "2") ? txtPib.Text : string.Empty;
            //order.Payment = (order.Name != string.Empty) ? new Payment(int.Parse(rdbPaymentCompany.SelectedValue), rdbPaymentCompany.SelectedItem.Text) : new Payment(int.Parse(rdbPayment.SelectedValue.ToString()), rdbPayment.SelectedItem.Text);
            order.Payment  = new Payment(int.Parse(rdbPayment.SelectedValue), rdbPayment.SelectedItem.Text);
            order.Delivery = new Delivery(int.Parse(rdbDelivery.SelectedValue.ToString()), rdbDelivery.SelectedItem.Text);
            CartBL cartBL = new CartBL();

            order.Coupon      = new Coupon(cartBL.GetCartCoupon(Session["cartID"].ToString()), string.Empty, 0, string.Empty, DateTime.Now, DateTime.Now, null, null);
            order.OrderStatus = new OrderStatus(1, string.Empty);
            order.Zip         = txtZip.Text;
            order.Comment     = txtRemark.Text;
            order.CartID      = Session["cartID"].ToString();


            OrderBL orderBL = new OrderBL();

            orderBL.SaveOrder(order);
            return(order);
        }
Example #2
0
        private Order createOrder(User user)
        {
            Order order = new Order();

            order.Date      = DateTime.Now.ToUniversalTime();
            order.Firstname = txtFirstname.Text;
            order.Lastname  = txtLastname.Text;
            order.Address   = txtAddress.Text;
            order.City      = txtCity.Text;
            order.Phone     = txtPhone.Text;
            order.Email     = txtEmail.Text;
            order.Items     = getItems();
            //order.User = new User(userID, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, null, string.Empty, string.Empty, DateTime.Now, string.Empty, 0, 1);
            order.User     = user;
            order.Name     = (rdbUserType.SelectedValue == "2") ? txtCompanyName.Text : string.Empty;
            order.Pib      = (rdbUserType.SelectedValue == "2") ? txtPib.Text : string.Empty;
            order.Payment  = (order.Name != string.Empty) ? new Payment(int.Parse(rdbPaymentCompany.SelectedValue), rdbPaymentCompany.SelectedItem.Text) : new Payment(int.Parse(rdbPayment.SelectedValue.ToString()), rdbPayment.SelectedItem.Text);
            order.Delivery = new Delivery(int.Parse(rdbDelivery.SelectedValue.ToString()), rdbDelivery.SelectedItem.Text);
            CartBL cartBL = new CartBL();

            order.Coupon      = new Coupon(cartBL.GetCartCoupon(Session["cartID"].ToString()), string.Empty, 0, string.Empty, DateTime.Now, DateTime.Now, new CouponType(-1, string.Empty), null);
            order.OrderStatus = new OrderStatus(1, string.Empty);
            order.Zip         = txtZip.Text;
            order.Comment     = txtRemark.Text;
            order.CartID      = Session["cartID"].ToString();

            double total = 0;

            foreach (OrderItem item in order.Items)
            {
                if (!bool.Parse(ConfigurationManager.AppSettings["userDiscountOnlyOnProductNotOnPromotion"]) || item.ProductPrice == item.UserPrice)
                {
                    total += item.UserPrice * item.Quantity;
                }
            }

            order.UserDiscountValue = user.DiscountTypeID == 1 ? total * user.Discount / 100 : user.Discount;



            OrderBL orderBL = new OrderBL();

            orderBL.SaveOrder(order);
            return(order);
        }