// string mailBody = "<div><b>" + user.FirstName + "שלום</b>" + //"<p>Bookmark תודה שהשתמשת בשרותי </p>" + //"<p>מקוים שנהנית</p>" + //"<p>" + book.NameBook + "הספר" + //"" + library.NameLibrary + "מחכה לך בספריה" + //"<p>:קוד השאלה</p>" + //"<h3>" + lending.IdLending + "</h3>" + //"<p>נשמח לעמוד לשרותכם תמיד</p></div>"; public static Books checkLending(int code) { Lendings lending = DalLending.checkLending(code); BooksInLibrary book = DalLending.lendingBook(lending.IdBook); return DalBook.getBookObj(book.IdBook); }
internal static BooksInLibrary BookInLibraryToModel(BooksInLibrary newBook) { return(new BooksInLibrary() { IdBook = newBook.IdBook, IdLibrary = newBook.IdLibrary, LendingDuration = newBook.LendingDuration, IdStatus = newBook.IdStatus }); }
public static bool changeStatus(int code) { int status; Lendings lending = DalLending.checkLending(code); BooksInLibrary book = DalLending.lendingBook(lending.IdBook); if (book.IdStatus == 3) status = 1; else status = 2; return DalBook.changeStatus(lending.IdBook, status); }
public HttpResponseMessage addBook([FromBody] BooksInLibrary newBook) { try { return(Request.CreateResponse(HttpStatusCode.OK, BLBook.addBook(newBook))); } catch (IOException e) { return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, e)); } }
public static bool deleteBook(int bookId) { BooksInLibrary book = Connect.db.BooksInLibrary.FirstOrDefault(b => b.IdBook == bookId); if (book != null) { Connect.db.BooksInLibrary.Remove(book); Connect.db.SaveChanges(); return(true); } return(false); }
public static bool addBook(BooksInLibrary newBook) { try { Connect.db.BooksInLibrary.Add(Convertors.BookInLibraryConvert.BookInLibraryToModel(newBook)); Connect.db.SaveChanges(); return(true); } catch (IOException e) { return(false); } }
public static int checkStatus(int code) { Lendings lending = DalLending.checkLending(code); BooksInLibrary book = DalLending.lendingBook(lending.IdBook); if (book.IdStatus == 2) { return -1; } else if (book.IdStatus == 1) return checkDaysForFree(code); else return 0; }
public static bool changeStatus(int idBook, int idStatus) { BooksInLibrary book = Connect.db.BooksInLibrary.FirstOrDefault(b => b.IdBookInLibrary == idBook);//retrieval the book according the Id if (book != null) { try { book.IdStatus = idStatus; Connect.db.SaveChanges(); return(true); } catch (IOException e) { return(false); } } return(false); }
public static bool editBook(BooksInLibrary book) { try { BooksInLibrary b = Connect.db.BooksInLibrary.FirstOrDefault(bl => bl.IdBookInLibrary == book.IdBookInLibrary); if (b != null) { b.IdBook = book.IdBook; b.IdLibrary = book.IdLibrary; b.LendingDuration = book.LendingDuration; b.StatusLending = book.StatusLending; Connect.db.SaveChanges(); return(true); } return(false); } catch (IOException e) { return(false); } }
public static bool addLending(Lendings lending) { BooksInLibrary book = BLBook.getBook(lending.IdBook);//gettin book according to bookId Users user = BLUser.getUser(lending.IdUser);//gettin user according to userId lending.StartDate = DateTime.Now;//setting the lend date for today lending.EndDate = lending.StartDate.AddDays(Convert.ToDouble(book.LendingDuration)); //setting the lend expiration date for today plus the borrowing time Lendings newLending = DalLending.addLending(lending);//add new lending if (newLending != null) { if (changeBookStatuse(lending.IdBook, 3)) //3 means catch-statusLending table(1-borrowed,2-free,3-catch) { Books bookObj = BLBook.getBookObj(book.IdBook); string mailSubject = "lending book"; if (BLSendinMail.SendingEmail(buildMailBodyForLending(lending, user.FirstName, bookObj.NameBook), mailSubject, user.EMail))//sending mail { return true; } else { DalLending.deleteLending(newLending.IdLending);//if can't send email deleting the lending from the DB return false; } } else { DalLending.deleteLending(newLending.IdLending);//if can't change the status of the book(to catch) deleting the lending from the DB return false; } } else { return false;//if can't create the new lending deleting the lending from the DB } }
public static bool addBook(BooksInLibrary newBook) { newBook.IdStatus = 2; return DalBook.addBook(newBook); }