public void DisplayTopRated()
        {
            BookManager manager = new BookManager();
            List <Book> Books   = manager.getlistofAllBooksInDB(ConfigurationManager.ConnectionStrings["GeekTextConnection"].ConnectionString);

            Books.OrderByDescending(o => o.bookRating);
            Book BookOne = Books[0];

            BestSellerOneImg.ImageUrl = "data:image;base64," + Convert.ToBase64String(Books[0].bookCover);
            BestSellerOnePrice.Text   = Books[0].price.ToString();
            BSOneHF.Value             = BookOne.ISBN;
            AuthorNameTROne.Text      = Books[0].bookAuthor.authorName.ToString();
            Book BookTwo = Books[1];

            BestSellerTwoPrice.Text   = Books[1].price.ToString();
            BestSellerTwoImg.ImageUrl = "data:image;base64," + Convert.ToBase64String(Books[1].bookCover);
            AuthorNameTRTwo.Text      = Books[1].bookAuthor.authorName.ToString();
            BSTwoHF.Value             = BookTwo.ISBN;
            Book BookThree = Books[2];

            BestSellerThreePrice.Text   = Books[2].price.ToString();
            AuthorNameTRThree.Text      = Books[2].bookAuthor.authorName.ToString();
            BSThreeHF.Value             = BookThree.ISBN;
            BestSellerThreeImg.ImageUrl = "data:image;base64," + Convert.ToBase64String(Books[2].bookCover);
        }
Example #2
0
    //自定义根据isbn查询信息的方法
    public void DisplayBook(string isbn)
    {
        Book book = BookManager.Getbookisbn(isbn);

        //调用方法
        info(book);
    }
Example #3
0
    //自定义根据id查询信息的方法
    public void DisplayBookByid(int id)
    {
        Book book = BookManager.GetbookisByid(id);

        //调用方法
        info(book);
    }
Example #4
0
        //
        // GET: /Book/Edit/5

        public ActionResult Edit(Guid id)
        {
            Book book = BookManager.Get(id);

            ViewBag.BookCollection = new SelectList(BookCollectionManager.GetAll(), "Id", "Title", book.BookCollection.Id);
            return(View(book));
        }
Example #5
0
 void Start()
 {
     _bookManager = GameObject.Find("BookManager").GetComponent <BookManager>();
     _selection   = GameObject.Find("SelectionManager").GetComponent <Selection>();
     bookButton   = gameObject.GetComponent <Button>();
     bookButton.onClick.AddListener(_bookManager.OpenCloseBook);
 }
Example #6
0
        // GET: BookDetail
        public ActionResult Index(string isbn)
        {
            BookManager DBbook = new BookManager();
            Book        book   = new Book();

            book = DBbook.getBook(isbn);

            if (book.Title == null)
            {
                book.Title = "unknown";
            }
            if (book.PublicationYear == null)
            {
                book.PublicationYear = "unknown";
            }
            if (book.pages == null)
            {
                book.pages = 0;
            }
            if (book.publicationinfo == null)
            {
                book.publicationinfo = "unknown";
            }

            return(View("BookDetail", book));
        }
        public void Start()
        {
            BookManager manager = new BookManager();

            BookFilter isNovel      = BookFilters.IsNovel;
            BookFilter isRomance    = BookFilters.IsRomance;
            BookFilter isShortStory = BookFilters.IsShortStory;
            BookFilter isFantasy    = BookFilters.IsFantasy;
            BookFilter isMyster     = BookFilters.IsMystery;
            BookFilter isCheap      = BookFilters.IsCheap;
            BookFilter isExpensive  = BookFilters.IsExpensive;

            Console.WriteLine("Novels: ");
            manager.PrintWhere(isNovel);

            Console.WriteLine("\nRomance: ");
            manager.PrintWhere(isRomance);

            Console.WriteLine("\nShorty Story: ");
            manager.PrintWhere(isShortStory);

            Console.WriteLine("\nFantasy: ");
            manager.PrintWhere(isFantasy);

            Console.WriteLine("\nMystery: ");
            manager.PrintWhere(isMyster);

            Console.WriteLine("\nCheap books that costs less than 100 SEK: ");
            manager.PrintWhere(isCheap);

            Console.WriteLine("\nExpensive books that costs more than 100 SEK: ");
            manager.PrintWhere(isExpensive);
        }
Example #8
0
        public ActionResult Detail(int id)
        {
            BookManager         manager             = new BookManager();
            BookDetailViewModel bookDetailViewModel = manager.GetSingleBookDetail(id);

            return(View(bookDetailViewModel));
        }
Example #9
0
 private void Page_Loaded_1(object sender, RoutedEventArgs e)
 {
     if (!String.IsNullOrEmpty(BookManager.getSingleton().StartPage.Background.ToString()))
     {
         imgBackground.Source = new BitmapImage(new Uri(BookManager.getSingleton().StartPage.Background.ToString()));
     }
     if (!String.IsNullOrEmpty(BookManager.getSingleton().StartPage.ListenImage.ToString()))
     {
         imgSoundImage.Source     = new BitmapImage(new Uri(BookManager.getSingleton().StartPage.ListenImage.ToString()));
         lblSoundImage.Visibility = Visibility.Hidden;
     }
     if (!String.IsNullOrEmpty(BookManager.getSingleton().StartPage.ListenImageClicked.ToString()))
     {
         imgSoundImage_Clicked.Source     = new BitmapImage(new Uri(BookManager.getSingleton().StartPage.ListenImageClicked.ToString()));
         lblSoundImage_CLicked.Visibility = Visibility.Hidden;
     }
     if (!String.IsNullOrEmpty(BookManager.getSingleton().StartPage.ReadImage.ToString()))
     {
         imgReadImage.Source     = new BitmapImage(new Uri(BookManager.getSingleton().StartPage.ReadImage.ToString()));
         lblReadImage.Visibility = Visibility.Hidden;
     }
     if (!String.IsNullOrEmpty(BookManager.getSingleton().StartPage.ReadImageClicked.ToString()))
     {
         imgReadImag_Clicked.Source      = new BitmapImage(new Uri(BookManager.getSingleton().StartPage.ReadImageClicked.ToString()));
         lblReadImage_Clicked.Visibility = Visibility.Hidden;
     }
 }
Example #10
0
    protected void btnRate_Click(object sender, EventArgs e)
    {
        // check whether the user has already rated this article
        int userRating = GetUserRating();

        if (userRating > 0)
        {
            ShowUserRating(userRating);
        }
        else
        {
            // rate the article, then create a cookie to remember this user's rating
            userRating = ddlRatings.SelectedIndex + 1;
            _bookID    = Convert.ToInt32(Request.QueryString["bid"]);
            Book book = BookManager.GetBookById(_bookID);
            book.Votes++;
            book.TotalRating += userRating;
            BookManager.ModifyBook(book);

            ShowUserRating(userRating);

            HttpCookie cookie = new HttpCookie(
                "Rating_Article" + _bookID.ToString(), userRating.ToString());
            cookie.Expires = DateTime.Now.AddDays(15);
            this.Response.Cookies.Add(cookie);
            Response.Redirect("BookDetail.aspx?bid=" + _bookID);
        }
    }
        public ActionResult AddBook(AddBookViewModel addBookViewModel)
        {
            if (ModelState.IsValid)
            {
                var blResultBook = new BookManager().AddBook(addBookViewModel);

                if (blResultBook.ErrorMessageObj.Count > 0)
                {
                    ErrorViewModel errorViewModel = new ErrorViewModel()
                    {
                        Items          = blResultBook.ErrorMessageObj,
                        RedirectingUrl = "/Book/AddBook"
                    };
                    return(View("Error", errorViewModel));
                }
                OkViewModel okViewModel = new OkViewModel()
                {
                    Title = "Yeni kitap eklendi.."
                };

                return(View("Ok", okViewModel));
            }
            //ViewBag.Categories = new SelectList(blResultCategory.BlResultList, "Id", "Name");
            return(View(addBookViewModel));
        }
Example #12
0
    // Ensure that menu state is current with the book state.
    private void retrieveSettings()
    {
        BookManager bm = GetComponentInParent <BookManager> ();

        currentPage = bm.getCurrentPage();
        fontSize    = bm.getFontSize();
    }
Example #13
0
        public ActionResult Delete(int id)
        {
            BookManager manager    = new BookManager();
            bool        deleteBook = manager.DeleteBook(id, User.Identity.GetUserId());

            return(Redirect(Request.UrlReferrer?.ToString()));
        }
Example #14
0
        private void imgReadImage_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            OpenFileDialog open = new OpenFileDialog();

            if (open.ShowDialog() == true)
            {
                string itemName = open.FileName;
                if (itemName.EndsWith(".png", true, null) || itemName.EndsWith(".jpg", true, null))
                {
                    var selectedImg = new BitmapImage(new Uri(itemName));
                    if (selectedImg.PixelHeight <= 150 && selectedImg.PixelWidth <= 150)
                    {
                        BookManager.getSingleton().StartPage.ReadImage = itemName;
                        imgReadImage.Source     = selectedImg;
                        lblReadImage.Visibility = System.Windows.Visibility.Hidden;
                    }
                    else
                    {
                        incorrectButtonSize(150, 150);
                    }
                }
                else
                {
                    incorrectImageFormat();
                }
            }
        }
Example #15
0
        protected void Page_Load(object sender, EventArgs e)
        {
            CKFinder.FileBrowser fileBrowser = new CKFinder.FileBrowser();
            fileBrowser.BasePath = "../ckfinder/";  //设置CKFinder的基路径
            fileBrowser.SetupCKEditor(txtContent);
            BindView();
            string bookname;

            if (!IsPostBack)
            {
                try
                {
                    if (Request.QueryString["book_name"] != null)
                    {
                        bookname = Request.QueryString["book_name"].ToString();
                        BookManager.delete(bookname);
                        BindView();
                        Page.ClientScript.RegisterClientScriptBlock(typeof(Object), "alert", "<script>alert('删除成功!');</script>");
                    }
                }
                catch (Exception ex)
                {
                    Response.Write("错误原因:" + ex.Message);
                }
            }
        }
        private int getBookPath(string dbPath, string bookId, string account, string meetingId)
        {
            int result = 0;

            try
            {
                BookManager bookManager = new BookManager(dbPath);
                result = getUserBookSno(dbPath, bookId, account, meetingId);
                if (!result.Equals(-1))
                {
                    return(result);
                }
                string text  = "Insert into bookInfo( bookId, account, meetingId )";
                string text2 = text;
                text = text2 + " values('" + bookId + "', '" + account + "', '" + meetingId + "')";
                bookManager.sqlCommandNonQuery(text);
                result = getBookPath(dbPath, bookId, account, meetingId);
                return(result);
            }
            catch (Exception ex)
            {
                LogTool.Debug(ex);
                return(result);
            }
        }
        private string AddOrUpdateBooksInReturnOrder(string orderID, List <Book> books)
        {
            Table <DAL.BookReturned> bookOrderTable = GetBookReturnTable();

            DeleteBookInReturnOrder(orderID);
            BookManager bkManager = new BookManager();

            foreach (Book book in books)
            {
                DAL.BookReturned data = new DAL.BookReturned();
                try
                {
                    data.orderID = orderID;
                    data.bookID  = book.BookID;

                    bookOrderTable.InsertOnSubmit(data);
                    bookOrderTable.Context.SubmitChanges();
                }
                catch (Exception ex)
                {
                    return(ex.Message);
                }

                bkManager.SetBookStatus(book.BookID, 1);
            }
            return("");
        }
Example #18
0
        protected void Page_Load(object sender, EventArgs e)
        {
            BookManager bookManager = new BookManager();

            bookGridView.DataSource = bookManager.GetAllBooks();
            bookGridView.DataBind();
        }
        public async Task ReturnAsyncTestAsync()
        {
            try
            {
                var unitOfWork = new UnitOfWork(new LibraryDbContext());
                var bm         = new BookManager(unitOfWork);

                var rent = (await unitOfWork.Rents.GetAllAsync()).Take(1).Single();

                var user = rent.Reader;
                var book = rent.Book;

                await bm.ReturnAsync(book, user);

                var rents = (await unitOfWork.Rents.FindByConditionAsync(r => r.Reader.Id == user.Id && r.Book.Id == book.Id));

                if (rents.Count() == 0)
                {
                    Assert.IsTrue(true);
                }
            }
            catch (Exception)
            {
                Assert.Fail();
            }
        }
Example #20
0
        public ActionResult Index()
        {
            if (Session["User"] == null)
            {
                return(View("~/Views/Shared/Unauthorized.cshtml"));
            }

            BookValidatior bookValidator  = new BookValidatior();
            var            smartIsbn      = (Request["newISBN"] == Request["oldISBN"])? "0" : Request["newISBN"];
            var            validateResult = bookValidator.validate(Request["Title"], smartIsbn, Request["pages"], Request["PublicationInfo"], Request.Form["authors"].Split(',').ToList());

            if (validateResult.Count == 0)
            {
                BookManager BookEdit = new BookManager();
                BookEdit.editBook(Request["Title"], Request["newISBN"], Request["pages"], Request["PublicationInfo"], Request.Form["authors"].Split(',').ToList(), Request["oldISBN"]);

                return(View("Edited"));
            }
            else
            {
                ViewBag.Validation = validateResult;

                Index(Request["oldISBN"]);

                return(View("bookEdit"));
            }
        }
Example #21
0
        // GET: BookEdit
        public ActionResult Index(string isbn)
        {
            if (Session["User"] == null)
            {
                return(View("~/Views/Shared/Unauthorized.cshtml"));
            }

            BookManager DBbook = new BookManager();
            Book        book   = new Book();

            book = DBbook.getBook(isbn);

            if (book.Title == null)
            {
                book.Title = "unknown";
            }
            if (book.PublicationYear == null)
            {
                book.PublicationYear = "unknown";
            }
            if (book.pages == null)
            {
                book.pages = 0;
            }
            if (book.publicationinfo == null)
            {
                book.publicationinfo = "unknown";
            }

            return(View("bookEdit", book));
        }
Example #22
0
    void Start()
    {
        thePlayer = FindObjectOfType <PlayerManager>();
        theDB     = FindObjectOfType <DatabaseManager>();
        theBook   = FindObjectOfType <BookManager>();

        /*
         * for(int i=0;i<blur.Length;i++){
         *  blurList.Add(blur[i]);
         * }*/
        doorStateBackup     = new bool[50];
        doorStateBackup[3]  = true;
        doorStateBackup[5]  = true;
        doorStateBackup[9]  = true;
        doorStateBackup[11] = true;
        doorStateBackup[13] = true;
        doorStateBackup[15] = true;
        doorStateBackup[17] = true;
        doorStateBackup[18] = true;
        doorStateBackup[19] = true;
        doorStateBackup[22] = true;
        doorStateBackup[23] = true;
        doorStateBackup[25] = true;
        doorStateBackup[26] = true;
        doorStateBackup[28] = true;
        doorStateBackup[29] = true;
        doorStateBackup[30] = true;
        doorStateBackup[31] = true;
        doorStateBackup[32] = true;
        doorStateBackup[34] = true;
        doorStateBackup[35] = true;
        doorStateBackup[37] = true;
        doorStateBackup[39] = true;
        doorStateBackup[40] = true;
    }
        private void label1_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            if (this.cbPages.SelectedIndex > -1)
            {
                OpenFileDialog open = new OpenFileDialog();

                if (open.ShowDialog() == true)
                {
                    string itemName = open.FileName;
                    if (itemName.EndsWith(".png", true, null) || itemName.EndsWith(".jpg", true, null))
                    {
                        var selectedImg = new BitmapImage(new Uri(itemName));
                        if (selectedImg.PixelHeight == 480 && selectedImg.PixelWidth == 800)
                        {
                            BookManager.getSingleton().ActivePage.Background = open.FileName;
                            this.label1.Visibility = System.Windows.Visibility.Hidden;
                            RefreshBackground();
                        }
                        else
                        {
                            MessageBox.Show("The image must have a size of 480x800 pixels", "Incorrect size", MessageBoxButton.OK, MessageBoxImage.Exclamation);
                        }
                    }
                    else
                    {
                        MessageBox.Show("Please choose a .png or .jpg image file", "Incorrect format", MessageBoxButton.OK, MessageBoxImage.Exclamation);
                    }
                }
            }
            else
            {
                MessageBox.Show("You must select an existing page before adding anything to it!", "Empty page", MessageBoxButton.OK, MessageBoxImage.Exclamation);
            }
        }
Example #24
0
        public async Task <bool> Contains(Offer of, bool first = true, int limit = 20, int count = 0)
        {
            if (count == limit)
            {
                return(false);
            }

            count++;

            if (first && (await Pool.Contains(of) || BookManager.ContainsOffer(of)))
            {
                return(true);
            }

            if (CurrentBlock != null)
            {
                if (CurrentBlock.OffersDictionary.ContainsKey(of.HashStr))
                {
                    return(true);
                }

                if (Previous != null)
                {
                    return(await Previous.Contains(of, false, limit, count));
                }
            }

            return(false);
        }
Example #25
0
        public ActionResult IndexPost()
        {
            if (Session["User"] == null)
            {
                return(View("~/Views/Shared/Unauthorized.cshtml"));
            }

            var title           = Request.Form["Title"];
            var ISBN            = Request.Form["ISBN"];
            var pages           = Request.Form["pages"];
            var publicationInfo = Request.Form["PublicationInfo"];
            var signID          = Request.Form["signId"];
            var authors         = Request.Form["authors"].Split(',').ToList();

            BookValidatior bookValidator  = new BookValidatior();
            var            validateResult = bookValidator.validate(title, ISBN, pages, publicationInfo, authors);

            if (validateResult.Count == 0)
            {
                BookManager newBook = new BookManager();
                newBook.createBook(title, ISBN, pages, publicationInfo, signID, authors);
                return(View("CreateBook"));
            }
            else
            {
                ViewBag.Validation = validateResult;
                return(View("CreateBook"));
            }
        }
Example #26
0
        static async Task MainAsync(string[] args)
        {
            var manager = new BookManager();
            await manager.Add("CLR via PHP", "Jeffrey Richter", "Fantasy");

            var books = await manager.GetAll();

            foreach (var book in books)
            {
                foreach (var item in book)
                {
                    Console.Write($"{item} ");
                }
                Console.WriteLine();
            }

            //var book =

            //foreach (var item in book) {
            //    Console.WriteLine(item);
            //}


            //var client = new HttpClient();
            //var url = "http://xam150.azurewebsites.net/api/books";
            //client.DefaultRequestHeaders.Add("Authorization", "f3ae2a49-a398-496f-b4d0-068e9531dcda");
            //// f3ae2a49-a398-496f-b4d0-068e9531dcda

            //    Book book = new Book() {
            //        Title = "CLR via C#",
            //        Authors = new List<string>(new[] { "Jeffrey Richter" }),
            //        ISBN = string.Empty,
            //        Genre = "Fantasy",
            //        PublishDate = DateTime.Now.Date,
            //    };

            //    var response = await client.PostAsync(url,
            //        new StringContent(
            //            JsonConvert.SerializeObject(book),
            //            Encoding.UTF8, "application/json"));

            //    Console.WriteLine(JsonConvert.DeserializeObject<Book>(
            //        await response.Content.ReadAsStringAsync()));
            //}


            //var response = await client.GetAsync(url);
            //if (response.StatusCode == HttpStatusCode.OK) {
            //    var content = response.Content;
            //    var data = await content.ReadAsStringAsync();
            //    var books = JsonConvert.DeserializeObject<Book[]>(data);
            //    foreach (var item in books) {
            //        Console.WriteLine($"{item.Title} {item.Authors.FirstOrDefault()}\n");
            //    }
            //} else if (response.StatusCode == HttpStatusCode.Unauthorized) {
            //    Console.WriteLine("Shalom, you need to get new token");
            //} else {
            //    Console.WriteLine();
            //}
        }
Example #27
0
        private void ShowAllBook(string searchBook)
        {
            BookManager bookManager = new BookManager();

            BookGridView.DataSource = bookManager.GetAllBook(searchBook);
            BookGridView.DataBind();
        }
 public HlsPlayer(string title, string bookId, string userId, string BookPath, byte[] defaultKey, string sourcePath, int userBookSno, long hlsLastTime, BookManager bookManager)
 {
     a();
     Text = title;
     h    = BookPath;
     l    = defaultKey;
     i    = sourcePath;
     j    = userBookSno;
     k    = hlsLastTime;
     m    = bookManager;
     f    = bookId;
     g    = userId;
     if (!b())
     {
         if (System.Windows.MessageBox.Show(m.LanqMng.getLangString("grantUrlaclMsg"), m.LanqMng.getLangString("grantUrlacl"), MessageBoxButton.YesNo, MessageBoxImage.Exclamation).Equals(MessageBoxResult.Yes))
         {
             c();
         }
         else
         {
             p = true;
         }
     }
     if (!p)
     {
         e = new Thread(new ParameterizedThreadStart(SimpleListenerExample));
         e.Start(new string[1]
         {
             "http://+:9000/"
         });
         Thread.Sleep(1);
     }
 }
 public ActionResult AddBook(Book newBook, int?authorID)
 {
     try
     {
         bool isAuthorized = Administrator.IsAuthorized((string)(Session["UserSession"]), (int)(Session["UserRank"]), (int)Authorization.Rank.administrator);
         if (isAuthorized)
         {
             if (!BookManager.DoesIsbnExist(newBook.ISBN))
             {
                 if (ModelState.IsValid)
                 {
                     BookManager.AddABook(newBook, authorID);
                     return(RedirectToAction("ListBooks", "Book"));
                 }
             }
             else
             {
                 TempData["Error"] = "Something went wrong!";
                 return(RedirectToAction("AddBook"));
             }
         }
     }
     catch (Exception ex)
     {
         TempData["Error"] = "Something went wrong!";
         return(RedirectToAction("listBooks", "Book"));
     }
     TempData["Error"] = "Something went wrong!";
     return(RedirectToAction("AddBook"));
 }
        // ListBooks sends the user to the "ListBooks" view where all the books in the databse are listen and separated by pagination
        public ActionResult ListBooks(int?page)
        {
            IList <Book> allBooks         = BookManager.GetBookList();
            int          currentPageIndex = page.HasValue ? page.Value - 1 : 0;

            return(View("ListBooks", allBooks.ToPagedList(currentPageIndex, DefaultPageSize)));
        }
 public JsonResult BookByCategory(string filterKey)
 {
     try
     {
         var model = new BookManager().GetBookByCategory(filterKey.Trim());
         return Json(model, JsonRequestBehavior.AllowGet);
     }
     catch (Exception ex)
     {
         Response.StatusCode = (int)HttpStatusCode.BadRequest;
         return Json(ex.Message, JsonRequestBehavior.AllowGet);
     }
 }
 public JsonResult BookByAuthor(string filterKey)
 {
     try
     {
         string[] keywords = filterKey.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);
         var model = new BookManager().GetBookByAuthor(keywords);
         return Json(model, JsonRequestBehavior.AllowGet);
     }
     catch (Exception ex)
     {
         Response.StatusCode = (int)HttpStatusCode.BadRequest;
         return Json(ex.Message, JsonRequestBehavior.AllowGet);
     }
 }
Example #33
0
        // 构造函数
        public MainPage()
        {
            InitializeComponent();
            var bar = GetTemplateChild("VerticalScrollBar");
            _manager = new BookManager(App.Current.CurrentBook);

            //ListBox.ListBox.ItemsSource = _manager.List;

            ListBox.ItemsSource = _manager.Book;

            ListBox.Inited += ListBox_Loaded;

            LayoutRoot.AddHandler(Grid.TapEvent, new EventHandler<System.Windows.Input.GestureEventArgs>(Page_Taped), true);
            Menu.Visibility = System.Windows.Visibility.Collapsed;
        }
        public FileContentResult ReturnBookInPdf(string isbn)
        {
            try
            {

                var bytes = new BookManager().GetPdf(Convert.ToInt64(isbn));

                const string mimeType = "application/pdf";

                var content = new System.Net.Mime.ContentDisposition
                {
                    FileName = "Test.pdf",
                    Inline = true
                };

                Response.AppendHeader("Content-Disposition", content.ToString());
                return File(bytes, mimeType);
            }
            catch (Exception)
            {
                return null;

            }
        }
 // GET: Book
 public ActionResult Index()
 {
     var model = new BookManager().GetAllBooks();
     return View(model);
 }