// public static User InsertUser(User u) { if (UserData.isMailExist(u.email) == true) { return(null); } UsersTable ut = new UsersTable() { address = u.address, birthDate = u.birthDate, email = u.email, firstName = u.firstName, genderId = u.genderId.Code, houseNumber = u.houseNumber, lastName = u.lastName, neighborhood = u.neighborhood, password = u.password, phone = u.phone }; if (u.cityCode.Code == 0) { if (LookupBL.getLookupByName(Constants.CitiesTableName, u.cityCode.Desc) != null) { ut.cityCode = LookupBL.getLookupByName(Constants.CitiesTableName, u.cityCode.Desc).Code; } else { ut.CityTable = new CityTable() { name = u.cityCode.Desc } }; } else { ut.cityCode = u.cityCode.Code; } UsersTable dbUser = UserData.InsertUser(ut); if (dbUser != null) { BooksLibraryDAL.LookupData.refreshLookups(); User user = castUserTableToUser(dbUser); string message = "נרשמת בהצלחה לאתר BOOK A BOOK <br/>"; message += "מחכים לך הרבה מאוד ספרים מעינים , מחכים לך , צוות האתר "; sendEmailFunc.sendEmailAsync(user.email, user.firstName + " " + user.lastName, message, "אישור הרשמה"); return(user); } return(null); }
public static bool borrowBook(int idB, int idU) { //idU-השואל if (BooksLibraryDAL.LenderData.checkIfBookIsBorrow(idB) == false) { LendsTable lend = new LendsTable(); lend.bookId = idB; lend.bookIsActive = false; lend.borrowerId = idU; lend.date = DateTime.Now; lend.statusCode = LookupBL.getLookupByName(Constants.lendsStatusTableName, "ממתין לאישור").Code; if (BooksLibraryDAL.LenderData.borrowBook(lend) == true) {//הספר BooksTable bt = BooksData.getBookById(idB); //המשאיל UsersTable utL = UserData.getUserById(bt.lenderId); //השואל UsersTable ut = UserData.getUserById(lend.borrowerId); string bookName = ""; if (bt != null) { bookName = LookupBL.getLookupByCode(Constants.BooksNameTableName, bt.nameId).Desc; } string message = "<br/><br/>סיפרך "; message += bookName + " "; message += "ממתין לאישור על ידי "; if (ut != null) { message += ut.firstName + " " + ut.lastName + ", " + "טלפון ליצירת קשר:" + ut.phone + "<br/><br/>"; } message += "בכדי לאשר את ההשאלה יש להיכנס לאתר ולאשר , המבקש יצור עמך קשר "; // message += "http://localhost:56996/api/Book/testString"; // message += "<br/> <button> <a href=" + "http://localhost:56996/api/Book/testString" + "> אשר</a> </button>"; //נשלח מייל למשאיל sendEmailFunc.sendEmailAsync(utL.email, utL.firstName + " " + utL.lastName, message, "בקשה להשאלת ספר " + bookName); return(true); } else { return(false); } } return(false); }
public static string EditUser(User u) { UsersTable ut = new UsersTable() { id = u.id, address = u.address, birthDate = u.birthDate, //cityCode = u.cityCode.Code, email = u.email, firstName = u.firstName, genderId = u.genderId.Code, houseNumber = u.houseNumber, lastName = u.lastName, neighborhood = u.neighborhood, password = u.password, phone = u.phone }; if (u.cityCode.Code == 0) { if (LookupBL.getLookupByName(Constants.CitiesTableName, u.cityCode.Desc) != null) { ut.cityCode = LookupBL.getLookupByName(Constants.CitiesTableName, u.cityCode.Desc).Code; } else { ut.CityTable = new CityTable() { name = u.cityCode.Desc } }; } else { ut.cityCode = u.cityCode.Code; } string result = UserData.EditUser(ut); BooksLibraryDAL.LookupData.refreshLookups(); return(result); }
public static int InsertBook(Books b) { BooksTable bt = new BooksTable(); bt.numberOfViewers = 0; //אם הכנסת מחבר - if (b.autherId.Code == 0) { //בדוק האם קיים כזה מחבר if (LookupBL.getLookupByName(Constants.AutherTableName, b.autherId.Desc) != null) {//אם כן חבר בקשרי גומלין bt.autherId = LookupBL.getLookupByName(Constants.AutherTableName, b.autherId.Desc).Code; } else {//אם לא צור חדש bt.AutherTable = new AutherTable() { name = b.autherId.Desc }; } } else { bt.autherId = b.autherId.Code; } if (b.categoryId.Code == 0) { if (LookupBL.getLookupByName(Constants.BooksCategoryTableName, b.categoryId.Desc) != null) { bt.categoryId = LookupBL.getLookupByName(Constants.BooksCategoryTableName, b.categoryId.Desc).Code; } else { bt.BooksCategriesTable = new BooksCategriesTable() { name = b.categoryId.Desc }; } } else { bt.categoryId = b.categoryId.Code; } bt.description = b.description; bt.isBorrowed = false; bt.lenderId = b.lenderId; if (b.nameId.Code == 0) { if (LookupBL.getLookupByName(Constants.BooksNameTableName, b.nameId.Desc) != null) { bt.nameId = LookupBL.getLookupByName(Constants.BooksNameTableName, b.nameId.Desc).Code; } else { bt.BooksNameTable = new BooksNameTable() { name = b.nameId.Desc }; } } else { bt.nameId = b.nameId.Code; } bt.numOfPages = b.numOfPages; if (b.publishingId.Code == 0) { if (LookupBL.getLookupByName(Constants.PuplishingTableName, b.publishingId.Desc) != null) { bt.publishingId = LookupBL.getLookupByName(Constants.PuplishingTableName, b.publishingId.Desc).Code; } else { bt.PublishingTable = new PublishingTable() { name = b.publishingId.Desc }; } } else { bt.publishingId = b.publishingId.Code; } int result = BooksData.InsertBook(bt); //var httpRequest = HttpContext.Current.Request; //if (httpRequest.Files.Count > 0) //{ // foreach (string file in httpRequest.Files) // { // var postedFile = httpRequest.Files[file]; // var filePath = HttpContext.Current.Server.MapPath("~/Images/picBook" + result); // postedFile.SaveAs(filePath); // } //} BooksLibraryDAL.LookupData.refreshLookups(); return(result); }
public static void editBook(Books b) { BooksTable bt = new BooksTable(); bt.id = b.id; if (b.autherId.Code == 0) { //בדוק האם קיים כזה מחבר if (LookupBL.getLookupByName(Constants.AutherTableName, b.autherId.Desc) != null) {//אם כן חבר בקשרי גומלין bt.autherId = LookupBL.getLookupByName(Constants.AutherTableName, b.autherId.Desc).Code; } else {//אם לא צור חדש bt.AutherTable = new AutherTable() { name = b.autherId.Desc }; } } else { bt.autherId = b.autherId.Code; } if (b.categoryId.Code == 0) { if (LookupBL.getLookupByName(Constants.BooksCategoryTableName, b.categoryId.Desc) != null) { bt.categoryId = LookupBL.getLookupByName(Constants.BooksCategoryTableName, b.categoryId.Desc).Code; } else { bt.BooksCategriesTable = new BooksCategriesTable() { name = b.categoryId.Desc }; } } else { bt.categoryId = b.categoryId.Code; } bt.description = b.description; bt.isBorrowed = false; bt.lenderId = 1; if (b.nameId.Code == 0) { if (LookupBL.getLookupByName(Constants.BooksNameTableName, b.nameId.Desc) != null) { bt.nameId = LookupBL.getLookupByName(Constants.BooksNameTableName, b.nameId.Desc).Code; } else { bt.BooksNameTable = new BooksNameTable() { name = b.nameId.Desc }; } } else { bt.nameId = b.nameId.Code; } bt.numOfPages = b.numOfPages; if (b.publishingId.Code == 0) { if (LookupBL.getLookupByName(Constants.PuplishingTableName, b.publishingId.Desc) != null) { bt.publishingId = LookupBL.getLookupByName(Constants.PuplishingTableName, b.publishingId.Desc).Code; } else { bt.PublishingTable = new PublishingTable() { name = b.publishingId.Desc }; } } else { bt.publishingId = b.publishingId.Code; } BooksData.editBook(bt); BooksLibraryDAL.LookupData.refreshLookups(); return; }