Esempio n. 1
0
        public IActionResult Index()
        {
            var hds = hoadonRepository.GetAll();

            ViewBag.hds = hds;
            return(View());
        }
Esempio n. 2
0
        public string taoHoaDon(int idThe, int tongTien, int giamGia, int thanhTien)
        {
            string code = "";
            var    dsnu = dsnuRepository.GetAll();
            HoaDon hd   = new HoaDon();

            hd.TaiKhoan  = User.Identity.Name;
            hd.NgayLap   = DateTime.Now;
            hd.TongTien  = tongTien;
            hd.GiamGia   = giamGia;
            hd.ThanhTien = thanhTien;
            hd.TrangThai = 1;
            hoadonRepository.Add(hd);
            var hds = hoadonRepository.GetAll();

            foreach (var hd1 in hds)
            {
                if (hd1.TrangThai == 1)
                {
                    hd.Id        = hd1.Id;
                    hd.TrangThai = 2;
                    hoadonRepository.Update(hd);
                    break;
                }
            }
            foreach (var nut in dsnu)
            {
                if (nut.IdThe == idThe)
                {
                    ChiTietHoaDon cthd = new ChiTietHoaDon();
                    cthd.IdHD     = hd.Id;
                    cthd.IdNU     = nut.IdNU;
                    cthd.SoLuong  = nut.SoLuong;
                    cthd.TongTien = nut.TongTien;
                    cthdRepository.Add(cthd);
                }
            }
            foreach (var nut in dsnu)
            {
                if (nut.IdThe == idThe)
                {
                    dsnuRepository.Remove(nut);
                }
            }
            code = code + "<table class='table'>";
            code = code + "<thead>";
            code = code + "<tr>";
            code = code + "<th>Nuoc uong</th>";
            code = code + "<th>So luong</th>";
            code = code + "<th>Tong tien</th>";
            code = code + "</tr>";
            code = code + "</thead>";
            code = code + "</table>";
            return(code);
        }