public IActionResult GioHang()
        {
            var items = _gioHang.LayChiTietGioHang();

            _gioHang.ChiTietGioHang = items;

            var x = new GioHangViewModel
            {
                GioHang         = _gioHang,
                TongTienGioHang = _gioHang.TinhTongTienGioHang()
            };

            return(View(x));
        }
Esempio n. 2
0
        public void TaoDonHang(DonHang dh)
        {
            dh.NgayDat = DateTime.Now;

            dh.TongTien = _GioHangDb.TinhTongTienGioHang();

            _context.DonHangDb.Add(dh);

            var chitietgiohang = _GioHangDb.ChiTietGioHang;

            foreach (var c in chitietgiohang)
            {
                var chitietdonhang = new CTDonHang()
                {
                    SoLuong    = c.SoLuong,
                    ID_SanPham = c.SanPham.ID_SanPham,
                    ID_DonHang = dh.ID_DonHang,
                    Gia        = c.SanPham.DonGia
                };

                _context.CTDonHangDb.Add(chitietdonhang);
            }

            _context.SaveChanges();
        }
Esempio n. 3
0
        public void TaoDonHang(DonHang donHang)
        {
            donHang.NgayDat = DateTime.Now;

            donHang.TongTien = _gioHang.TinhTongTienGioHang();

            _csdl._DonHang.Add(donHang);

            var chitietgiohang = _gioHang.ChiTietGioHang;

            foreach (var c in chitietgiohang)
            {
                var chitietdonhang = new ChiTietDonHang()
                {
                    SoLuong   = c.SoLuong,
                    GiayID    = c.Giay.GiayID,
                    DonHangID = donHang.DonHangID,
                    Gia       = c.Giay.Gia
                };

                _csdl._ChiTietDonHang.Add(chitietdonhang);
            }

            _csdl.SaveChanges();
        }