コード例 #1
0
        public ActionResult Search(int?page, string Name)
        {
            List <Book> a = BookAction.SearchBook(Name);

            ViewBag.l = a;
            return(View());
        }
コード例 #2
0
        // GET: Book
        public ActionResult Index()
        {
            List <BookType> a = new List <BookType>();

            a = BookAction.ListBookType();
            return(PartialView(a));
        }
コード例 #3
0
        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));
            }
        }
コード例 #4
0
        public ActionResult Detail(int ID)
        {
            Book book = BookAction.FindBook(ID);

            ViewBag.Book = book;
            return(View());
        }
コード例 #5
0
 public BookReviewsPage(BookAction action, Book book)
 {
     InitializeComponent();
     BindingContext = vm = new BookReviewsViewModel(book);
     ba             = action;
     _book          = book;
 }
コード例 #6
0
        /* 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));
        }
コード例 #7
0
        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"));
        }
コード例 #8
0
        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)));
        }
コード例 #9
0
 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 }));
 }
コード例 #10
0
 public ActionResult ListBook()
 {
     if (Session["UserName"] != null && (int)Session["Role"] == 1)
     {
         ViewBag.ListBook = BookAction.ListBook();
         //AccountAction.
         return(View());
     }
     return(RedirectToAction("Login", "Account"));
 }
コード例 #11
0
        public ActionResult Add()
        {
            Book book = new Book
            {
                AuthorCollection   = AuthorAction.ListAuthor(),
                BookTypeCollection = BookAction.ListBookType()
            };

            ViewBag.ListBook = BookAction.ListBook();
            return(View(book));
        }
コード例 #12
0
 /* BOOK DETAIL */
 public ActionResult BookDetail(int Id)
 {
     if (Id != 0)
     {
         ViewBag.Book = BookAction.Find_Book(Id);
         return(View());
     }
     else
     {
         return(Redirect("~/Book/ShowBook"));
     }
 }
コード例 #13
0
        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));
        }
コード例 #14
0
 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"));
     }
 }
コード例 #15
0
        /* ------------------------------------------------------------- */



        /* 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));
        }
コード例 #16
0
        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"));
        }
コード例 #17
0
        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());
        }
コード例 #18
0
        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
            });
        }
コード例 #19
0
 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"));
     }
 }
コード例 #20
0
 public ActionResult ListTrinhTham(int ID)
 {
     ViewBag.ListTT = BookAction.ListTrinhTham(ID);
     return(View());
 }
コード例 #21
0
 public ActionResult Delete(int ID)
 {
     BookAction.DeleteBook(ID);
     return(RedirectToAction("ListBook", "Admin"));
 }
コード例 #22
0
 public ActionResult HomePage()
 {
     ViewBag.ListBook = BookAction.ListBook();
     return(View());
 }
コード例 #23
0
 public ActionResult AddCount(int ID)
 {
     ViewBag.Book = BookAction.FindBook(ID);
     return(View());
 }
コード例 #24
0
 /* Find Book By Name */
 public JsonResult FindBook(string name)
 {
     return(Json(BookAction.Find_Book(name), JsonRequestBehavior.AllowGet));
 }
コード例 #25
0
ファイル: ImportForm.cs プロジェクト: Gremlin2/bookscanner
        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;
        }
コード例 #26
0
 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"]));
 }
コード例 #27
0
 public ActionResult ShopGrid()
 {
     ViewBag.ListBook = BookAction.ListBook();
     return(View());
 }
コード例 #28
0
 /* Get Book By Page Number */
 public JsonResult GetAllBook(int page)
 {
     return(Json(BookAction.Show_Book(page, page_size), JsonRequestBehavior.AllowGet));
 }
コード例 #29
0
 /* jSON */
 public JsonResult IsAlreadyExist(string Ten_Sach)
 {
     return(Json(BookAction.find(Ten_Sach), JsonRequestBehavior.AllowGet));
 }
コード例 #30
0
 /* Find Book By Genre */
 public JsonResult GetBookByGenre(string name)
 {
     return(Json(BookAction.Get_Book_By_Genre(name), JsonRequestBehavior.AllowGet));
 }
コード例 #31
0
ファイル: ImportForm.cs プロジェクト: Gremlin2/bookscanner
        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();
        }
コード例 #32
0
 /* 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"]));
 }