protected void isbn_TextChanged(object sender, EventArgs e) { System.Threading.Thread.Sleep(1000); BookService.BookService service = new BookService.BookService(); Book book = service.checkBookExist(isbn.Text); if (book != null) { title.Value = book.title; author.Value = book.author; tag.Value = book.tag; language.Value = book.language; description.Value = book.description; disableInput(true); // idBookTxt.Value = book.id + ""; } else { title.Value = ""; author.Value = ""; tag.Value = ""; language.Value = ""; description.Value = ""; disableInput(false); } }
protected void Page_Load(object sender, EventArgs e) { // set title for page Page.Title = "Search result - BookShare"; if (!IsPostBack) { // check query search is null or not thing then redirect to home page if (Request.QueryString["query"] == null || Request.QueryString["query"].Trim() == "") { Server.Transfer("Home.aspx"); } listQuery.Add("All"); listQuery.Add("Title"); listQuery.Add("Author"); listQuery.Add("ISBN"); listQuery.Add("Tag"); string query = Request.QueryString["query"]; filter = Request.QueryString["filter"] == null ? "All" : Request.QueryString["filter"]; page = Request.QueryString["page"] == null ? 1 : int.Parse(Request.QueryString["page"]); BookService.BookService bookservice = new BookService.BookService(); books = bookservice.searchBook(query, filter, page).ToList(); totalPage = bookservice.getTotalPageSearch(filter, query); // } }
public void uploadCoverBook(int idUser, int idBook) { BookService.BookService bookservice = new BookService.BookService(); int maxSizeFile = 1024 * 1024 * 4; byte[][] arrbytes = new byte[5][]; string[] fileName = new string[5]; var arr = new FileUpload[] { cover1, cover2, cover3, cover4, cover5 }; int count = 0; foreach (FileUpload file in arr) { if (file.HasFile && file.FileContent.Length <= maxSizeFile && checkType(Path.GetExtension(file.FileName))) { BinaryReader br = new BinaryReader(file.PostedFile.InputStream); byte[] data = br.ReadBytes((int)file.PostedFile.InputStream.Length); arrbytes[count] = data; // string coverName = string.Format("{0}_{1}_cover{2}{3}", idBook, idUser, count + 1, Path.GetExtension(file.FileName)); fileName[count] = coverName; // count++; } } bookservice.uploadCoverBook(Server.MapPath("~"), fileName, arrbytes, idBook); }
protected void Page_Load(object sender, EventArgs e) { // set title for page Page.Title = "Book Details - BookShare"; if (Request.QueryString["id"] == null || Session["currentUser"] == null) { Server.Transfer("ErrorPage.aspx"); } else { user = (User)Session["currentUser"]; int.TryParse(Request.QueryString["id"], out idBook); // get idbook BookService.BookService bookservice = new BookService.BookService(); TradingService.TradingService tradingservice = new TradingService.TradingService(); book = bookservice.getBookById(idBook); tradings = tradingservice.getTradingByIdBook(idBook, user.id).ToList(); covers = bookservice.getBookCovers(idBook).ToList(); rootPath = Request.ApplicationPath; updateReview(10); } }
protected void sendReview_Click(object sender, EventArgs e) { BookService.BookService bookservice = new BookService.BookService(); bookservice.reviewBook(idBook, user.id, contentReview.Value); contentReview.Value = ""; System.Threading.Thread.Sleep(500); int top = int.Parse(selectTop.SelectedItem.Value); updateReview(top); }
protected void uploadBtn_Click(object sender, EventArgs e) { int idBook = 0; int.TryParse(idBookTxt.Value, out idBook); if (checkRules.Checked && Session["currentUser"] != null) { User user = (User)Session["currentUser"]; TradingService.TradingService tradingService = new TradingService.TradingService(); BookService.BookService bookService = new BookService.BookService(); if (bookService.checkBookExist(isbn.Text) == null) // if book not exist then create new book first { idBook = bookService.createBook(isbn.Text, title.Value, author.Value, tag.Value, language.Value, description.Value, user.id); uploadCoverBook(user.id, idBook); } string xx = user.id + ""; if (idBook != 0) { tradingService.createTrading(user.id, idBook); Server.Transfer(string.Format("BookDetails.aspx?id={0}", idBook)); } } }
public void updateReview(int top) { BookService.BookService bookservice = new BookService.BookService(); reviews = bookservice.getTopReview(top, idBook).ToList(); }