public ActionResult Search(int?page, string Name) { List <Book> a = BookAction.SearchBook(Name); ViewBag.l = a; return(View()); }
// GET: Book public ActionResult Index() { List <BookType> a = new List <BookType>(); a = BookAction.ListBookType(); return(PartialView(a)); }
public ActionResult Edit(int ID, string Name, string PublishingCompany, DateTime PublishingDate, string Size, int NumberOfPages, string CoverType, int BookTypeID, int AuthorID, double Price, HttpPostedFileBase file, int Discount) { Book book = new Book { AuthorCollection = AuthorAction.ListAuthor(), BookTypeCollection = BookAction.ListBookType() }; ViewBag.book = BookAction.FindBook(ID); try { string _path = ""; if (file.ContentLength > 0) { string _FileName = Path.GetFileName(file.FileName); _path = Path.Combine(Server.MapPath("~/UploadedFiles"), _FileName); file.SaveAs(_path); BookAction.EditFullBook(ID, Name, PublishingCompany, PublishingDate, Size, NumberOfPages, CoverType, BookTypeID, AuthorID, _FileName, Price, Discount); } ViewBag.Message = "Updated Successfully"; return(View(book)); } catch { ViewBag.Message = "Updated Fail!"; return(View(book)); } }
public ActionResult Detail(int ID) { Book book = BookAction.FindBook(ID); ViewBag.Book = book; return(View()); }
public BookReviewsPage(BookAction action, Book book) { InitializeComponent(); BindingContext = vm = new BookReviewsViewModel(book); ba = action; _book = book; }
/* JSON - ADD CART */ public JsonResult Add_Cart(int id) { if (Session["cart"] == null) { Dictionary <int, Item> list_item = new Dictionary <int, Item>(); list_item.Add(id, new Item { book = BookAction.Find_Book(id), so_luong = 1 }); Session["cart"] = list_item; } else { Dictionary <int, Item> list_item = (Dictionary <int, Item>)Session["cart"]; if (list_item.ContainsKey(id)) { var tmp = list_item[id]; tmp.so_luong = tmp.so_luong + 1; list_item[id] = tmp; } else { list_item.Add(id, new Item { book = BookAction.Find_Book(id), so_luong = 1 }); } } return(Json("Good", JsonRequestBehavior.AllowGet)); }
public ActionResult ViewCart() { ViewBag.BookTop = BookAction.AddSachTop5ToDb(); if (TempData["Alert"] != null) { ViewBag.Alert = TempData["Alert"].ToString(); } if (Session["UserName"] != null && (int)Session["Role"] == 2) { int AccountId = (int)Session["UserID"]; if (Session["UserID"] == null) { return(RedirectToAction("Login", "Account")); } var listCart = BillAction.ListCartDetail(AccountId); if (listCart != null) { ViewBag.ListCart = listCart; ViewBag.Detail = listCart.FirstOrDefault(); } return(View()); } return(RedirectToAction("Login", "Account")); }
public ActionResult Search(int?page, string Name) { int pageSize = 3; int pageNumber = (page ?? 1); List <Book> a = BookAction.SearchBook(Name); return(View(a.OrderBy(m => m.ID).ToPagedList(pageNumber, pageSize))); }
public ActionResult AddCount(int ID, int Count) { ViewBag.Book = BookAction.FindBook(ID); if (BookAction.AddCount(ID, Count)) { ViewBag.Book = BookAction.FindBook(ID); return(RedirectToAction("AddCount", new { ID })); } return(RedirectToAction("AddCount", new { ID })); }
public ActionResult ListBook() { if (Session["UserName"] != null && (int)Session["Role"] == 1) { ViewBag.ListBook = BookAction.ListBook(); //AccountAction. return(View()); } return(RedirectToAction("Login", "Account")); }
public ActionResult Add() { Book book = new Book { AuthorCollection = AuthorAction.ListAuthor(), BookTypeCollection = BookAction.ListBookType() }; ViewBag.ListBook = BookAction.ListBook(); return(View(book)); }
/* BOOK DETAIL */ public ActionResult BookDetail(int Id) { if (Id != 0) { ViewBag.Book = BookAction.Find_Book(Id); return(View()); } else { return(Redirect("~/Book/ShowBook")); } }
public ActionResult Edit(int ID) { ViewBag.book = BookAction.FindBook(ID); Book book = new Book(); using (var db = new BookContext()) { book.AuthorCollection = db.Authors.ToList(); book.BookTypeCollection = db.BookTypes.ToList(); } return(View(book)); }
public ActionResult EditBook(int Id) { if ((string)Session["role"] == "admin" || (string)Session["role"] == "staff") { ViewBag.Book = BookAction.Find_Book(Id); ViewBag.Genre = GenreAction.Get_All_Genre(); return(View()); } else { return(Redirect("~/Book/ShowBook")); } }
/* ------------------------------------------------------------- */ /* UPDATE IMAGE BOOK */ public ActionResult UpdateImg(int Id, HttpPostedFileBase File) { string path = ""; if (File.ContentLength > 0) { string File_Name = Path.GetFileName(File.FileName); path = Path.Combine(Server.MapPath("~/UploadFiles"), File_Name); File.SaveAs(path); BookAction.Update_Img(Id, File_Name); } RecordAction.Create_Record(CustomerAction.Find_Customer((int)Session["id"]).email, CustomerAction.Find_Customer((int)Session["id"]).email + " change image from " + BookAction.Find_Book(Id).ten_sach, DateTime.Now.Date); return(Redirect("~/Book/BookDetail/" + Id)); }
public ActionResult CreateBook(string Ten_Sach, string Tac_Gia, string The_Loai, string Nha_Xuat_Ban, string Mo_Ta, double Gia_Ban, HttpPostedFileBase File) { Book book = new Book(); string path = ""; if (File.ContentLength > 0) { string File_Name = Path.GetFileName(File.FileName); path = Path.Combine(Server.MapPath("~/UploadFiles"), File_Name); File.SaveAs(path); BookAction.Create_Book(Ten_Sach, Tac_Gia, The_Loai, Nha_Xuat_Ban, Mo_Ta, Gia_Ban, File_Name); } RecordAction.Create_Record(CustomerAction.Find_Customer((int)Session["id"]).email, CustomerAction.Find_Customer((int)Session["id"]).email + " create new book.", DateTime.Now.Date); return(Redirect("~/Book/CreateBook")); }
public ActionResult Detail(int ID) { Book book = BookAction.FindBook(ID); if (Session["UserName"] != null) { int id_account = (int)Session["UserID"]; BookAction.Watched(id_account, ID); } else { BookAction.Watched(null, ID); } ViewBag.Book = book; ViewBag.ListBook = BookAction.ListBook(); return(View()); }
public async Task Notify(BookAction action, Isbn isbn) { await _getQueueUrlTask; var messageObj = new BookChangeMessage { Action = action, Isbn = IsbnToString(isbn) }; var messageJson = JsonConvert.SerializeObject(messageObj, _serializerSettings); await _queue.SendMessageAsync(new SendMessageRequest() { QueueUrl = _getQueueUrlTask.Result, MessageBody = messageJson }); }
public ActionResult Add(string Name, string PublishingCompany, DateTime PublishingDate, string Size, int NumberOfPages, string CoverType, int BookTypeID, int AuthorID, double Price, HttpPostedFileBase file, int Discount) { try { string _path = ""; if (file.ContentLength > 0) { string _FileName = Path.GetFileName(file.FileName); _path = Path.Combine(Server.MapPath("~/UploadedFiles"), _FileName); file.SaveAs(_path); BookAction.AddBook(Name, PublishingCompany, PublishingDate, Size, NumberOfPages, CoverType, BookTypeID, AuthorID, _FileName, Price, Discount); } return(RedirectToAction("Add")); } catch { return(RedirectToAction("Add")); } }
public ActionResult ListTrinhTham(int ID) { ViewBag.ListTT = BookAction.ListTrinhTham(ID); return(View()); }
public ActionResult Delete(int ID) { BookAction.DeleteBook(ID); return(RedirectToAction("ListBook", "Admin")); }
public ActionResult HomePage() { ViewBag.ListBook = BookAction.ListBook(); return(View()); }
public ActionResult AddCount(int ID) { ViewBag.Book = BookAction.FindBook(ID); return(View()); }
/* Find Book By Name */ public JsonResult FindBook(string name) { return(Json(BookAction.Find_Book(name), JsonRequestBehavior.AllowGet)); }
private ImportStatus CreateOrReplace(Fb2DocumentEntry documentEntry, BookAction action, Stream stream) { ImportStatus importResult; FictionBook fictionBook; try { importResult = documentEntry.Status; using (MemoryStream memoryStream = new MemoryStream((int)documentEntry.FileSize)) { byte[] buffer = bufferPool.Aquire(); try { StreamUtils.Copy(stream, memoryStream, buffer); } finally { bufferPool.Release(buffer); } memoryStream.Seek(0, SeekOrigin.Begin); using (XmlTextReader reader = new XmlTextReader(memoryStream)) { XmlDocument document = new XmlDocument(); document.Load(reader); fictionBook = new FictionBook(document, reader.Encoding); memoryStream.Seek(0, SeekOrigin.Begin); switch(action) { case BookAction.Add: BookInfo bookInfo = this.database.CreateFictionBook(fictionBook, memoryStream, documentEntry); documentEntry.BookId = bookInfo.BookId; importResult = ImportStatus.Added; break; case BookAction.Update: bookInfo = database.LoadBookInfoByBookId(documentEntry.BookId ?? -1); this.database.UpdateFictionBook(bookInfo, fictionBook, memoryStream, documentEntry); importResult = ImportStatus.Updated; break; } this.processLegend.IncrementCounter(importResult); } } } catch (DatabaseException exp) { documentEntry.ErrorText = exp.Message; this.processLegend.IncrementCounter(ImportStatus.DatabaseError); importResult = ImportStatus.DatabaseError; } catch (InvalidFictionBookFormatException exp) { documentEntry.ErrorText = exp.Message; this.processLegend.IncrementCounter(ImportStatus.ParsingError); importResult = ImportStatus.ParsingError; } catch (XmlException exp) { documentEntry.ErrorText = exp.Message; this.processLegend.IncrementCounter(ImportStatus.ParsingError); importResult = ImportStatus.ParsingError; } catch (IOException exp) { documentEntry.ErrorText = exp.Message; this.processLegend.IncrementCounter(ImportStatus.ParsingError); importResult = ImportStatus.ParsingError; } return importResult; }
public ActionResult EditBook(int Id, string Ten_Sach, string Tac_Gia, string The_Loai, string Nha_Xuat_Ban, string Mo_Ta, double Gia_Ban) { BookAction.Edit_Book(Id, Ten_Sach, Tac_Gia, The_Loai, Nha_Xuat_Ban, Mo_Ta, Gia_Ban); RecordAction.Create_Record(CustomerAction.Find_Customer((int)Session["id"]).email, CustomerAction.Find_Customer((int)Session["id"]).email + " update book " + Ten_Sach, DateTime.Now.Date); return(Redirect("~/Book/BookManager/" + Session["id"])); }
public ActionResult ShopGrid() { ViewBag.ListBook = BookAction.ListBook(); return(View()); }
/* Get Book By Page Number */ public JsonResult GetAllBook(int page) { return(Json(BookAction.Show_Book(page, page_size), JsonRequestBehavior.AllowGet)); }
/* jSON */ public JsonResult IsAlreadyExist(string Ten_Sach) { return(Json(BookAction.find(Ten_Sach), JsonRequestBehavior.AllowGet)); }
/* Find Book By Genre */ public JsonResult GetBookByGenre(string name) { return(Json(BookAction.Get_Book_By_Genre(name), JsonRequestBehavior.AllowGet)); }
private void CreateOrReplace(Fb2DocumentEntry documentEntry, BookAction action) { IFileObject fileObject = manager.resolveFile(documentEntry.Filename); ImportFileEntry entry = null; if (excludeList.ContainsKey(documentEntry.Filename)) { entry = excludeList[documentEntry.Filename]; } try { try { this.processLegend.DecrementCounter(documentEntry.Status); using (Stream stream = fileObject.Content.InputStream) { try { documentEntry.Status = CreateOrReplace(documentEntry, action, stream); } finally { stream.Close(); } } if (entry != null) { entry.Status = documentEntry.Status; } } catch (Exception exp) { Logger.WriteError(exp.Message); Logger.WriteLine(TraceEventType.Verbose, exp); documentEntry.Status = ImportStatus.ParsingError; documentEntry.ErrorText = exp.Message; if (entry != null) { entry.Status = documentEntry.Status; } this.processLegend.IncrementCounter(ImportStatus.ParsingError); } } finally { manager.closeFileSystem(fileObject.FileSystem); } this.grdResult.RefreshDataSource(); this.grdLegend.RefreshDataSource(); Application.DoEvents(); }
/* DELETE BOOK */ public ActionResult DeleteBook(int Id) { BookAction.Delete_Book(Id); RecordAction.Create_Record(CustomerAction.Find_Customer((int)Session["id"]).email, CustomerAction.Find_Customer((int)Session["id"]).email + " delete book " + BookAction.Find_Book(Id).ten_sach, DateTime.Now.Date); return(Redirect("~/Book/BookManager/" + Session["id"])); }