public async Task <IActionResult> EditPost(int id, string tinhTrang)
        {
            var donHang = await _hoadonRepo.getById(id);

            donHang.TinhTrang = tinhTrang;

            await _hoadonRepo.Update(donHang);

            return(Redirect("/admin/order"));
        }
Beispiel #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);
        }
Beispiel #3
0
        public async Task <bool> CancelOrder(int id)
        {
            var userid = _userManager.GetUserId(User);
            var order  = await _hoadonRepository.getById(id);

            if (order.UserId != userid)
            {
                return(false);
            }
            if (order.TinhTrang != Status.ChoXacNhan)
            {
                return(false);
            }
            ;
            order.TinhTrang = Status.DaHuy;
            await _hoadonRepository.Update(order);

            return(true);
        }
Beispiel #4
0
 public void Update(HoaDon hoaDon)
 {
     _hoaDonRepository.Update(hoaDon);
 }
Beispiel #5
0
 public bool Update(HoaDonModel model)
 {
     return(_res.Update(model));
 }