コード例 #1
0
 public EmailResult GoiMailThanhToan(CartViewModel.OrderModel model)
 {
     To.Add(model.CartForm.Email);
     CC.Add("*****@*****.**");
     From    = "*****@*****.**";
     Subject = "Đơn đặt hàng tại Beautygarden";
     return(Email("GoiMailThanhToan", model));
 }
コード例 #2
0
        public ActionResult Success(int id)
        {
            DetailMenuComment order = _detailMenuCommentRepository.GetById(id);

            if (order == null)
            {
                return(RedirectToRoute("Home"));
            }

            IList <DetailMenuCommentItem> details =
                _detailMenuCommentItemRepository.GetMany(o => o.id_Menu == order.id_).ToList();

            IList <CartViewModel.CartItem> cartItems = (from o in details
                                                        select new CartViewModel.CartItem
            {
                ProductId = Convert.ToInt32(o.Link),
                Name = o.Name,
                Image = o.Img,
                Price = Convert.ToInt32(o.Price),
                PricePromotion = Convert.ToInt32(o.PriceOf),
                Barcode = o.BarCode,
                Quantity = Convert.ToInt32(o.Number)
            }).ToList();

            CartViewModel.OrderModel cartModel = new CartViewModel.OrderModel()
            {
                CartItems = cartItems,
                Total     = cartItems.Sum(o => o.Quantity * o.PricePromotion),
                orderIdForremarketting = id, // lấy Id để truyền vào hàm remarketing
                CartForm = new CartViewModel.CartForm()
                {
                    Name        = order.Name,
                    Phone       = order.Link,
                    Address     = order.GiaoHang,
                    Email       = order.HuongDanSuDung,
                    Note        = order.Content,
                    ShipAddress = order.GiaoHang,
                    BrandName   = GetBrands().FirstOrDefault(o => o.Id == order.idBrand).Name
                }
            };
            //gửi mail thanh toán đơn hàng
            // new MailersController().GoiMailThanhToan(cartModel).Deliver();

            return(View("Success", cartModel));
        }
コード例 #3
0
        public ActionResult ViewOrder(int id)
        {
            DetailMenuComment order = _detailMenuCommentRepository.GetById(id);

            if (order == null)
            {
                return(RedirectToRoute("Home"));
            }

            IList <DetailMenuCommentItem> details =
                _detailMenuCommentItemRepository.GetMany(o => o.id_Menu == order.id_).ToList();

            IList <CartViewModel.CartItem> cartItems = (from o in details
                                                        select new CartViewModel.CartItem
            {
                ProductId = Convert.ToInt32(o.Link),
                Name = o.Name,
                Image = o.Img,
                Price = Convert.ToInt32(o.Price),
                PricePromotion = Convert.ToInt32(o.PriceOf),
                Barcode = o.BarCode,
                Quantity = Convert.ToInt32(o.Number),
            }).ToList();


            CartViewModel.OrderModel cartModel = new CartViewModel.OrderModel()
            {
                CartItems = cartItems,
                Order     = order,

                Total    = cartItems.Sum(o => o.Quantity * o.PricePromotion),
                CartForm = new CartViewModel.CartForm()
                {
                    Name        = order.Name,
                    Phone       = order.Link,
                    Address     = order.GiaoHang,
                    Email       = order.HuongDanSuDung,
                    Note        = order.Content,
                    ShipAddress = order.GiaoHang,
                    BrandName   = GetBrands().FirstOrDefault(o => o.Id == order.idBrand).Name
                }
            };

            return(View("ViewOrder", cartModel));
        }
コード例 #4
0
        public ActionResult Index()
        {
            //thanh toan don hang
            IList <CartViewModel.ProductCart> productCarts = new List <CartViewModel.ProductCart>();
            CookieHelper cookieHelper = new CookieHelper("Cart");

            if (cookieHelper.GetCookie() != null)
            {
                string json = HttpUtility.UrlDecode(cookieHelper.GetCookie().Values["Cart"]);
                productCarts = JsonConvert.DeserializeObject <List <CartViewModel.ProductCart> >(json);
            }

            IList <ProductFrontPageMapping.ProductShowCart> productShowCarts =
                _menuRepository.GetProductShowCartByBarcode(productCarts.Select(o => o.Barcode).ToList());
            IList <PromotionMapping.PromotionCheckProduct> promotions = _promotionRepository.GetActives();
            IList <CartViewModel.CartItem> cartItems = new List <CartViewModel.CartItem>();
            int gia = 0;

            if (productCarts.Any())
            {
                foreach (var o in productCarts)
                {
                    IList <ProductStockSyncMapping.TonKho> tonKhos = _productStockSyncRepository.GetTonKhoCuaSanPham(o.ProductId);
                    var tonkho = tonKhos.FirstOrDefault(t => t.Barcode.Equals(o.Barcode));
                    var item   = productShowCarts.FirstOrDefault(p => p.Barcode.Equals(o.Barcode));
                    if (item != null)
                    {
                        #region ghép combo < 80K
                        if (item.Price < 80000 && o.Quantity >= 2)
                        {
                            //nếu số lượng > 2  và giá < 80000 bắt đầu tính giá combo
                            int giatru = (item.Price * 10) / 100;
                            gia = item.Price - giatru;
                        }
                        else
                        {
                            gia = item.Price;
                        }
                        #endregion

                        var cartItem = new CartViewModel.CartItem()
                        {
                            ProductId      = o.ProductId,
                            Name           = item.NameProduct,
                            Image          = item.Img,
                            Link           = item.Link,
                            Price          = item.Price,
                            PricePromotion = gia,
                            Barcode        = o.Barcode,
                            Quantity       = o.Quantity,
                            AttributeImg   = item.AttributeImg,
                            AttributeName  = item.AttributeName,
                            AttributeFlag  = item.AttributeFlag,
                            Available      = tonkho != null && tonkho.OnHand >= o.Quantity
                        };
                        #region check promotion
                        if (promotions.Any())
                        {
                            foreach (var pr in promotions)
                            {
                                var promotionDetail = pr.PromotionDetails.FirstOrDefault(dt => dt.ProductId == cartItem.ProductId);
                                if (promotionDetail != null)
                                {
                                    cartItem.HasPromotion   = true;
                                    cartItem.PricePromotion = (int)promotionDetail.PriceDiscount;
                                    cartItem.Discount       = (short)promotionDetail.Percent;
                                    break;
                                }
                            }
                        }

                        #endregion
                        cartItems.Add(cartItem);
                    }
                }
            }
            CartViewModel.OrderModel cartModel = new CartViewModel.OrderModel()
            {
                CartItems = cartItems,
                Total     = cartItems.Sum(o => o.Quantity * o.PricePromotion),
                CartForm  = new CartViewModel.CartForm()
            };
            return(View("Index", cartModel));
        }