示例#1
0
        public JsonResult OrderItem(ShopCartVm obj)
        {
            ShopCartVm _vm = new ShopCartVm();
            IRepositryOrder <Fly_Order> repositryOrder = new OrderDao();
            bool isSuccess = false;

            try
            {
                using (TransactionScope scope = new TransactionScope())
                {
                    _vm.Order.BillingAddress1    = obj.CustomerAttr.StreetAddress;
                    _vm.Order.BillingEmail       = obj.Customer.Email;
                    _vm.Order.BillingFirstName   = obj.CustomerAttr.FirstName;
                    _vm.Order.BillingLastName    = obj.CustomerAttr.LastName;
                    _vm.Order.BillingPhoneNumber = obj.CustomerAttr.MobilePhone.ToString();
                    _vm.Order.CreatedOn          = DateTime.Now;
                    _vm.Order.CustomerID         = obj.Customer.CustomerID;
                    _vm.Order.Deleted            = false;
                    _vm.Order.ShippingStatusID   = 1;
                    _vm.Order.OrderGUID          = Guid.NewGuid();
                    _vm.Order.OrderTotal         = obj.Order.OrderTotal;
                    _vm.Order.BillingCountryID   = obj.SelectIndexCountry;
                    _vm.Order.ShippingMethodID   = obj.SelectIndexShipping;
                    _vm.Order.BillingCity        = obj.Order.BillingCity;
                    _vm.Order.DeliveryDate       = DateTime.ParseExact(obj.DeliveryDate, "dd/MM/yyyy",
                                                                       CultureInfo.InvariantCulture);
                    _vm.Order.OrderStatus       = OrderStatus.NotYetApprove;
                    _vm.Order.PaymentMethodName = obj.SelectNamePaymentMethod;

                    //
                    _vm.OrderProductVariant.ProductVariantID        = obj.ProductVariant.ProductVariantId;
                    _vm.OrderProductVariant.Price                   = obj.OrderProductVariant.Price;
                    _vm.OrderProductVariant.OrderID                 = _vm.Order.OrderID;
                    _vm.OrderProductVariant.OrderProductVariantGUID = Guid.NewGuid();
                    _vm.OrderProductVariant.Quantity                = obj.OrderProductVariant.Quantity;
                    _vm.Order.Fly_OrderProductVariant.Add(_vm.OrderProductVariant);

                    //
                    _vm.OrderNote.OrderID           = _vm.Order.OrderID;
                    _vm.OrderNote.Note              = "Order status has been changed to Not Yet Approve";
                    _vm.OrderNote.DisplayToCustomer = false;
                    _vm.OrderNote.CreatedOn         = DateTime.Now;
                    _vm.Order.Fly_OrderNote.Add(_vm.OrderNote);

                    //
                    repositryOrder.Add(_vm.Order);



                    scope.Complete();
                    scope.Dispose();
                    isSuccess = true;
                }
            }
            catch (Exception ex)
            {
                isSuccess = false;
            }
            return(Json(new { rs = isSuccess }));
        }
示例#2
0
        public ActionResult AddOrder(ShopingCart shop_new, string ngayhoanthanh)
        {
            ShopingCart shop      = (ShopingCart)Session["DonHang"];
            OrderDao    order_dao = new OrderDao();

            shop.TenKhachHang   = shop_new.TenKhachHang;
            shop.DiaChiGiaoHang = shop_new.DiaChiGiaoHang;
            shop.TenKhachHang   = shop_new.TenKhachHang;
            // shop.NgayHoanThanh = DateTime.Now;
            shop.NgayHoanThanh = DateTime.Parse(ngayhoanthanh);
            order_dao.Add(shop);
            Session["DonHang"] = null;
            return(RedirectToAction("HomePage", "HomePage"));
        }