public IActionResult Save([Bind("maPhieuMuon,maSach,maDocGia,ngayMuon")] LichSuMuon lichSu) { var book = _context.Sach.Find(lichSu.maSach); book.tinhTrang = "unvailable"; if (ModelState.IsValid) { _context.LichSuMuon.Add(lichSu); _context.SaveChanges(); _context.Sach.Update(book); _context.SaveChanges(); return(RedirectToAction(nameof(Return))); } return(View(lichSu)); }
public async Task <IActionResult> BorrowDetail(int?id) { if (id == null) { return(NotFound()); } var book = await _context.Sach.FindAsync(id); if (book == null) { return(NotFound()); } var ls = new LichSuMuon(); ls.maSach = book.maSach; return(View(ls)); }