public void BanAn_Load() { IEnumerable <PhieuDatBan> phieuDatBans = QLNHContext.PhieuDatBans.Where(s => s.TrangThai == "Chưa xử lý"); // cập nhật trạng thái bàn đặt trước, nếu qua thời gian quy đinh thì sẽ bị hủy TimeSpan aInterval = new System.TimeSpan(0, -1, -30, 0); // trừ một khoảng thời gian. DateTime day = DateTime.Now; DateTime dayNow = DateTime.Now; day = day.Add(aInterval); var banDatTruocs = QLNHContext.BanAns.Where(s => s.TrangThai == "Được đặt trước"); foreach (BanAn ban in banDatTruocs) { foreach (PhieuDatBan p in phieuDatBans) { int compare = DateTime.Compare(day, p.ThoiGianDat); if (compare > 0 && ban.Id == p.IdBanAn) { ban.TrangThai = "Trống"; Update(ban); p.TrangThai = "Bị hủy"; QLNHContext.Entry(p).State = EntityState.Modified; QLNHContext.SaveChanges(); } } } // cập nhật trạng thái bàn trống,nếu có người đặt bàn mà chưa tới giờ phục vụ // thì trong khoảng thời gian phục vụ tồi đa là 3 tiếng // thì sẽ cập nhật bàn ăn là dc đặt trước day = DateTime.Now; var banTrongs = QLNHContext.BanAns.Where(s => s.TrangThai == "Trống"); foreach (BanAn ban in banTrongs) { foreach (PhieuDatBan p in phieuDatBans) { DateTime.Compare(day, p.ThoiGianDat); if (ban.Id == p.IdBanAn && (DateTime.Compare(day, p.ThoiGianDat + new TimeSpan(0, -3, 0, 0)) >= 0 && DateTime.Compare(day, p.ThoiGianDat + new TimeSpan(0, 1, 30, 0)) <= 0)) { ban.TrangThai = "Được đặt trước"; Update(ban); QLNHContext.SaveChanges(); } } } }
public async Task ThemCTHD(int IdHoaDon, int IdMonAn, int SoLuong) { ThucDon td = QLNHContext.ThucDons.Where(s => s.Id == IdMonAn).FirstOrDefault(); ChiTietHoaDon chiTiet = QLNHContext.ChiTietHoaDons.Where(s => s.IdHoaDon == IdHoaDon && s.IdMonAn == IdMonAn).FirstOrDefault(); if (chiTiet == null) { ChiTietHoaDon ct = new ChiTietHoaDon { IdHoaDon = IdHoaDon, IdMonAn = IdMonAn, SoLuong = SoLuong, DonGia = td.Gia * SoLuong }; await QLNHContext.ChiTietHoaDons.AddAsync(ct); } else { chiTiet.SoLuong = SoLuong; chiTiet.DonGia = SoLuong * td.Gia; QLNHContext.Entry(chiTiet).State = Microsoft.EntityFrameworkCore.EntityState.Modified; } }
public NguoiDungRepository(QLNHContext context) : base(context) { }
public void Update(NguoiDung NguoiDung) { QLNHContext.Entry(NguoiDung).State = EntityState.Modified; }
public void Update(ThucDon td) { QLNHContext.Entry(td).State = EntityState.Modified; }
public ThucDonRepository(QLNHContext context) : base(context) { }
public PhieuDatBanRepository(QLNHContext context) : base(context) { }
public void Update(BanAn banAn) { QLNHContext.Entry(banAn).State = EntityState.Modified; }
public BanAnRepository(QLNHContext context) : base(context) { }
public KhachHangRepository(QLNHContext context) : base(context) { }
public LoaiMonAnRepository(QLNHContext context) : base(context) { }
public void DeleteCTHD(int IdHoaDon, int IdMonAn) { ChiTietHoaDon chiTiet = QLNHContext.ChiTietHoaDons.Where(s => s.IdHoaDon == IdHoaDon && s.IdMonAn == IdMonAn).FirstOrDefault(); QLNHContext.Entry(chiTiet).State = Microsoft.EntityFrameworkCore.EntityState.Deleted; }
public void Update(HoaDon HoaDon) { QLNHContext.Entry(HoaDon).State = Microsoft.EntityFrameworkCore.EntityState.Modified; }
public HoaDonRepository(QLNHContext context) : base(context) { }