//mv 05-03-2019 public static bool returnBook(int idLender) { try { using (BooksLibraryProjectEntities db = new BooksLibraryProjectEntities()) { LendsTable lend = db.LendsTable.Where(l => l.id == idLender).FirstOrDefault(); if (lend != null) { if (lend.statusCode == 2) { lend.BooksTable.isBorrowed = false; lend.statusCode = 4; lend.date = DateTime.Now; db.SaveChanges(); return(true); } } } } catch (Exception ex) { throw ex; } return(false); }
public static bool rejectBorrow(int idBorrow) { try { using (BooksLibraryProjectEntities db = new BooksLibraryProjectEntities()) { LendsTable lend = db.LendsTable.Where(l => l.id == idBorrow).FirstOrDefault(); if (lend != null) { if (lend.statusCode == 1) { lend.statusCode = 3; BooksTable bt = db.BooksTable.Where(b => b.id == lend.bookId).FirstOrDefault(); if (bt != null) { bt.isBorrowed = false; } db.SaveChanges(); return(true); } } } } catch (Exception ex) { throw ex; } return(false); }
public static bool borrowBook(LendsTable lend) { try { using (BooksLibraryProjectEntities db = new BooksLibraryProjectEntities()) { db.LendsTable.Add(lend); BooksTable b = db.BooksTable.Where(x => x.id == lend.bookId).FirstOrDefault(); b.isBorrowed = true; db.SaveChanges(); } return(true); } catch (Exception ex) { throw ex; } return(false); }