public void editRentDetail(ChiTietMuon e) { ChiTietMuon obj = db.ChiTietMuons.SingleOrDefault(x => x.MaPhieuMuon == e.MaPhieuMuon && x.MaSach == e.MaSach); obj.SoLuong = e.SoLuong; db.SaveChanges(); }
public void deleteRentDetail(int rentCardId, int bookId) { ChiTietMuon e = db.ChiTietMuons.SingleOrDefault(x => x.MaPhieuMuon == rentCardId && x.MaSach == bookId); db.ChiTietMuons.Remove(e); db.SaveChanges(); }
public string createRentDetail(ChiTietMuon e) { ChiTietMuon obj = db.ChiTietMuons.SingleOrDefault(x => x.MaPhieuMuon == e.MaPhieuMuon && x.MaSach == e.MaSach); PhieuMuon rentcard = db.PhieuMuons.SingleOrDefault(x => x.MaPhieuMuon == e.MaPhieuMuon); DocGia reader = db.DocGias.SingleOrDefault(x => x.MaDocGia == rentcard.MaDocGia); LoaiTheThuVien cardtype = db.LoaiTheThuViens.SingleOrDefault(x => x.MaLoaiThe == reader.MaLoaiThe); if (obj == null) { if (countQuantityBookBorrowed(rentcard.MaPhieuMuon) + e.SoLuong <= cardtype.SoSachToiDa) { db.ChiTietMuons.Add(e); db.SaveChanges(); return("Thêm mới thành công!"); } else { return("Thẻ của bạn không thể mượn quá số lượng!"); } } else { if (e.SoLuong <= cardtype.SoSachToiDa) { obj.SoLuong = e.SoLuong; db.SaveChanges(); return("Bản ghi đã tồn tại. Chỉ có thể thay đổi số lượng!"); } else { return("Thẻ của bạn không thể mượn quá số lượng!"); } } }