public ActionResult ChiTietdonhang(int id) { DetailMenuComment donHang = _detailMenuCommentRepository.GetById(id); IList <DetailMenuCommentItem> chiTietDonHangs = donHang.ChiTietDonHangs.ToList(); OrderModel model = new OrderModel() { DonHang = donHang, ChiTietDonHangs = chiTietDonHangs }; return(View(model)); }
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)); }