public void ReturnBook(BookIssuance issuance) { if(!issuance.RealReturnDate.HasValue) { issuance.RealReturnDate = DateTime.Now; _context.SaveChanges(); } }
public bool GiveBook(int userId, int bookId, DateTime requredReturnDate) { var newIssuance = new BookIssuance { UserId = userId, BookId = bookId, RequiredReturnDate = requredReturnDate, IssuanceDate = DateTime.Now }; if (!_context.Users.ToList().Single(u => u.UserId == userId).IsBanned) { _context.BookIssuances.Add(newIssuance); _context.SaveChanges(); return true; } return false; }