public static string Getnovellist(string m_where, int Top, int CutTitle, string Model) { StringBuilder sb = new StringBuilder(); var NovelList = BookView.GetModelList(m_where, Top.ToInt32()); foreach (var b in NovelList) { string str = Model; str = str.Replace("{id}", b.ID.ToS()); str = str.Replace("{title}", b.Title.CutString(CutTitle)); str = str.Replace("{author}", b.Author); str = str.Replace("{classid}", b.ClassID.ToS()); str = str.Replace("{classname}", b.ClassName); str = str.Replace("{clickcount}", b.ClickCount.ToS()); str = str.Replace("{lastchapterid}", b.LastChapterID.ToS()); str = str.Replace("{lastchaptertitle}", b.LastChapterTitle); str = str.Replace("{tjcount}", b.TjCount.ToS()); str = str.Replace("{url}", BasePage.GetBookUrl(b, BookView.GetClass(b))); sb.Append(str); } return(sb.ToS()); }
/// <summary> /// 获取最新更新的书籍 /// </summary> /// <param name="top"></param> /// <returns></returns> public string getnoveltopupdate(string top) { int i_top = top.ToInt32(); List <Book> bs = BookView.GetModelList("Enable=1 order by UpdateTime desc", i_top); StringBuilder sb = new StringBuilder(); //foreach (Book b in bs) for (int i = 0; i < bs.Count; i++) { Book b = bs[i]; Class c = BookView.GetClass(b); string str_style = ""; if (i % 2 == 0) { str_style = " style=\"background-color: #f5f5f5\""; } sb.AppendLine(string.Format("<tr" + str_style + "><td>[<a target=\"_blank\" href=\"{0}\" class=\"sort\">{1}</a>]</td><td><a class=\"name\" target=\"_blank\" href=\"{2}\">{3}</a> <a target=\"_blank\" href=\"{4}\" class=\"chapter\">{5}</a></td><td><a target=\"_blank\" href=\"/Search.aspx?m=4&key={6}\" class=\"author\">{6}</a></td><td style=\"color: #666666\">{7}</td></tr>", BasePage.GetClassUrl(c), b.ClassName, BasePage.GetBookUrl(b, c), b.Title, BasePage.GetBookChapterUrl(BookChapterView.GetModelByID(b.LastChapterID.ToS()), c), b.LastChapterTitle, b.Author, b.UpdateTime.ToString("MM-dd HH:mm") )); } return(sb.ToS()); }
/// <summary> /// 获取小说列表 /// </summary> /// <param name="m_where"></param> /// <returns></returns> public static string getnovellist(string m_where, string Top, string CutTitle, string firstClass, string ShowClickCount) { StringBuilder sb = new StringBuilder(); var NovelList = BookView.GetModelList(m_where, Top.ToInt32()); foreach (var b in NovelList) { string str_cls = ""; if (firstClass.Length > 0 && b == NovelList.First()) { str_cls = " class=\"" + firstClass + "\""; } string str_clickcount = ""; if (ShowClickCount.ToBoolean()) { str_clickcount = string.Format("<span>{0}</span>", b.ClickCount); } sb.Append(string.Format("<li" + str_cls + "><a title=\"{0}\" href=\"{1}\">{2}</a>{3}</li>", b.Title, BasePage.GetBookUrl(b, BookView.GetClass(b)), b.Title.CutString(CutTitle.ToInt32(10)), str_clickcount)); } return(sb.ToS()); }
public ActionResult Edit(BookView model, HttpPostedFileBase imageBook, int genre, int author) { string str = "check"; var bookBO = mapper.Map <BookBO>(model); byte[] imageData = null; if (imageBook != null) { using (var binaryReader = new BinaryReader(imageBook.InputStream)) { imageData = binaryReader.ReadBytes(imageBook.ContentLength); } bookBO.ImageData = imageData; } else { bookBO.ImageData = new byte[str.Length]; } bookBO.GenreId = genre; bookBO.AuthorId = author; bookBO.Save(); var books = DependencyResolver.Current.GetService <BookBO>().GetBooksList(); var authorList = DependencyResolver.Current.GetService <AuthorBO>().GetAuthorsList(); var genreList = DependencyResolver.Current.GetService <GenreBO>().GetGenreList(); ViewBag.Authors = authorList.Select(m => mapper.Map <AuthorView>(m)).ToList(); ViewBag.Genres = genreList.Select(m => mapper.Map <GenreView>(m)).ToList(); //return RedirectToActionPermanent("Index", "Book"); return(PartialView("Partial/BookPartialView", books.Select(m => mapper.Map <BookView>(m)).ToList())); }
/// <summary> /// 获取最新更新的书籍 Metro风格 /// </summary> /// <param name="top"></param> /// <returns></returns> public string getnoveltopmetroupdate(string top) { int i_top = top.ToInt32(); List <Book> bs = BookView.GetModelList("Enable=1 order by UpdateTime desc", i_top); StringBuilder sb = new StringBuilder(); int i = 1; foreach (Book b in bs) { Class c = BookView.GetClass(b); sb.AppendLine(string.Format("<li style=\" background-color:{0};\"><div class=\"item\"><h1><a href=\"{1}\">" + i + ".{2}</a></h1><div><div class=\"lastchapter\"><a href=\"{5}\">{6}</a></div></div></div><div class=\"item\"><h1><a href=\"{1}\">阅读书籍</a></h1><div><div class=\"lastchapter\"><a href=\"{5}\" title=\"{6}\">阅读最新章节</a></div><div class=\"class\">分类:<a href=\"{3}\">{4}</a></div><div class=\"author\">作者:{8}</div><div class=\"time\">更新时间:{9}</div></div></div></li>", BasePage.RandomBGColor(), BasePage.GetBookUrl(b, c), b.Title, BasePage.GetClassUrl(c), b.ClassName, BasePage.GetBookChapterUrl(BookChapterView.GetModelByID(b.LastChapterID.ToS()), c), b.LastChapterTitle, b.LastChapterTitle.CutString(12), b.Author, b.UpdateTime.ToString("MM-dd HH:mm") )); i++; } return(sb.ToS()); }
/// <summary> /// 删除章节 /// </summary> /// <param name="id">章节ID</param> protected void ChapterDelete(long id) { try { var c = BookChapterView.GetModelByID(id.ToS()); var b = BookView.GetModelByID(c.BookID.ToS()); Class cls = BookView.GetClass(b); Voodoo.IO.File.Delete(Server.MapPath(BasePage.GetBookChapterTxtUrl(c, cls))); BookChapterView.DelByID(id); var lastChapter = BookChapterView.Find("BookId={0} order by ChapterIndex,id desc"); b.UpdateTime = lastChapter.UpdateTime; b.LastChapterID = lastChapter.ID; b.LastChapterTitle = lastChapter.Title; BookView.Update(b); Response.Clear(); Response.Write(Voodoo.IO.XML.Serialize(true)); } catch (System.Exception e) { Response.Clear(); Response.Write(Voodoo.IO.XML.Serialize(false)); } }
/// <summary> /// 生成章节 /// </summary> /// <param name="bookid">书籍ID</param> protected void CreateChapters(long chapterid) { try { var chapter = BookChapterView.GetModelByID(chapterid.ToS()); var book = BookView.GetModelByID(chapter.BookID.ToS()); var cls = BookView.GetClass(book); var pre = BasePage.GetPreChapter(chapter, book); Voodoo.Basement.CreatePage.CreateBookChapterPage(chapter, book, cls); if (pre != null && pre.ID > 0) { Voodoo.Basement.CreatePage.CreateBookChapterPage(pre, book, cls); } //var chapters = BookChapterView.GetModelList(string.Format("bookid={0}", bookid)); //foreach (var c in chapters) //{ // Voodoo.Basement.CreatePage.CreateBookChapterPage(c, BookView.GetBook(c), BookView.GetClass(c)); //} Response.Clear(); Response.Write(XML.Serialize(true)); } catch (System.Exception e) { Response.Clear(); Response.Write(XML.Serialize(false)); } }
/// <summary> /// 书籍编辑 /// </summary> /// <param name="id">ID</param> /// <param name="Title">标题</param> /// <param name="Author">作者</param> /// <param name="ClassID">类别ID</param> /// <param name="Intro">简介</param> /// <param name="Length">长度</param> protected void BookEdit(int id, string Title, string Author, int ClassID, string Intro, long Length) { Book b = BookView.GetModelByID(id.ToS()); string ClassName = ClassView.GetModelByID(ClassID.ToString()).ClassName; b.Title = Title.IsNull(b.Title); b.Author = Author.IsNull(b.Author); b.ClassID = ClassID.IsNull(b.ClassID); b.ClassName = ClassName.IsNull(b.ClassName); b.Intro = Intro.IsNull(b.Intro); b.Length = Length == 0 ? b.Length : Length; if (b.ID < 0) { Response.Clear(); Response.Write(Voodoo.IO.XML.Serialize(false)); } try { BookView.Update(b); Response.Clear(); Response.Write(Voodoo.IO.XML.Serialize(true)); } catch { Response.Clear(); Response.Write(Voodoo.IO.XML.Serialize(false)); } }
/// <summary> /// 设置书籍封面 /// </summary> /// <param name="id">书籍ID</param> /// <param name="files">上传文件</param> protected void SaveBookFace(int id, HttpFileCollection files) { try { Book b = BookView.GetModelByID(id.ToS()); string ImagePath = Server.MapPath("/Book/BookFace/" + id + ".jpg"); DirectoryInfo dir = new FileInfo(ImagePath).Directory; if (!dir.Exists) { dir.Create(); } if (Voodoo.IO.File.Exists(ImagePath)) { Voodoo.IO.File.Delete(ImagePath); } files[0].SaveAs(ImagePath); b.FaceImage = "/Book/BookFace/" + id + ".jpg"; BookView.Update(b); Response.Clear(); Response.Write(XML.Serialize(true)); } catch { Response.Clear(); Response.Write(XML.Serialize(false)); } }
/// <summary> /// 获取书籍 /// </summary> /// <param name="Title">标题</param> /// <param name="Author">作者</param> protected void GetBook(string Title, string Author) { Book b = BookView.Find(string.Format("Title=N'{0}' and Author=N'{1}'", Title, Author)); Response.Clear(); Response.Write(XML.Serialize(b)); }
/// <summary> /// 书籍搜索 /// </summary> /// <param name="Title">标题</param> /// <param name="Author">作者</param> /// <param name="Intro">简介</param> protected void SearchBook(string Title, string Author, string Intro) { var books = BookView.GetModelList(string.Format("Title like N'%{0}%' and Author like N'%{1}%' and Intro like N'%{2}%'", Title, Author, Intro)); Response.Clear(); Response.Write(XML.Serialize(books)); }
internal BookAssert ShouldBeSameAs(BookView expected, IDbConnection db) { _book.Should().NotBeNull(); _book.Title.Should().Be(expected.Title); _book.Description.Should().Be(expected.Description); _book.Language.Should().Be(expected.Language); _book.IsPublic.Should().Be(expected.IsPublic); _book.IsPublished.Should().Be(expected.IsPublished); _book.Copyrights.Should().Be(expected.Copyrights); _book.DateAdded.Should().BeCloseTo(expected.DateAdded); _book.DateUpdated.Should().BeCloseTo(expected.DateUpdated); _book.Status.Should().Be(expected.Status); _book.YearPublished.Should().Be(expected.YearPublished); _book.SeriesId.Should().Be(expected.SeriesId); _book.SeriesName.Should().Be(db.GetSeriesById(expected.SeriesId.Value).Name); _book.SeriesIndex.Should().Be(expected.SeriesIndex); var authors = db.GetAuthorsByBook(expected.Id); _book.Authors.Should().HaveSameCount(authors); foreach (var author in authors) { var actual = _book.Authors.SingleOrDefault(a => a.Id == author.Id); actual.Name.Should().Be(author.Name); actual.Link("self") .ShouldBeGet() .EndingWith($"libraries/{_libraryId}/authors/{author.Id}"); } _book.Categories.Should().HaveSameCount(expected.Categories); return(this); }
public ActionResult Create(BookView book, string[] selected, HttpPostedFileBase Image) { ExploreData.EditBook(book, selected, db, Image); return(RedirectToAction("Index")); }
public BookView Get(int id) { Book book = _unitOfWork.Book.Get(id); BookView bookView = MapToViewModel(book); return(bookView); }
public void ShouldDisplaySubmittingStatusAndDisableControlsBeforeBookSubmissionCompletes() { // given BookView someBookView = CreateRandomBookView(); this._bookViewServiceMock.Setup(service => service.AddBookViewAsync(It.IsAny <BookView>())) .ReturnsAsync( value: someBookView, delay: TimeSpan.FromMilliseconds(500)); // when _addBookComponent = RenderComponent <AddBookComponent>(); _addBookComponent.Instance.SubmitButton.Click(); // then _addBookComponent.Instance.StatusLabel.Value.Should().BeEquivalentTo("Submitting ... "); _addBookComponent.Instance.StatusLabel.Color.Should().Be(Color.Black); // _addBookComponent.Instance.IdTextBox.IsDisabled.Should().BeTrue(); _addBookComponent.Instance.Isbn13TextBox.IsDisabled.Should().BeTrue(); _addBookComponent.Instance.IsbnTextBox.IsDisabled.Should().BeTrue(); _addBookComponent.Instance.AuthorTextBox.IsDisabled.Should().BeTrue(); _addBookComponent.Instance.TitleTextBox.IsDisabled.Should().BeTrue(); _addBookComponent.Instance.SubtitleTextBox.IsDisabled.Should().BeTrue(); _addBookComponent.Instance.PublishDatePicker.IsDisabled.Should().BeTrue(); _addBookComponent.Instance.SubmitButton.IsDisabled.Should().BeTrue(); _bookViewServiceMock.Verify(service => service.AddBookViewAsync(It.IsAny <BookView>()), Times.Once); _bookViewServiceMock.VerifyNoOtherCalls(); }
/// <summary> /// Sets the amount of books specified by the user. /// </summary> /// <param name="book">Takes a book to change amount on</param> /// <param name="admin">Takes a user with admin priviliges</param> private static void SetAmount(Book book, User admin) { AdminView.SetAmount(); var input = SharedController.GetAndValidateInput(); if (input.validatedInput != 0) { WebShopApi api = new WebShopApi(); if (api.SetAmount(admin.Id, book.Id, input.validatedInput)) { if (book.Amount <= 0) { book.Amount = 0; } SharedError.Success(); BookView.ChangedNumberOfBooks(book); } else { SharedError.Failed(); BookView.ChangedNumberOfBooks(book); } } else { SharedError.PrintWrongMenuInput(); } }
private Book ConvertBook(BookView b) { var authorView = new List <Guid>(); var bookAuthors = new List <BookAuthor>(); foreach (var a in b.Authors) { var BA = new BookAuthor() { AuthorId = a.Id, }; bookAuthors.Add(BA); } var book = new Book() { Id = b.Id, Title = b.Title, ISBN = b.ISBN, Year = (int)b.Year, BooksAuthors = bookAuthors, }; return(book); }
public async Task <ActionResult> Edit([FromForm] Guid Id, string title, string ISBN, int year, IEnumerable <string> Authors) { var authors = new List <AuthorView>(); foreach (var id in Authors) { var a = await _httpAuthor.Get(Guid.Parse(id)); var av = Convert(a); if (a != null) { authors.Add(av); } } var bv = new BookView() { Id = Id, Title = title, ISBN = ISBN, Year = year, Authors = authors, }; try { var sendbook = ConvertBook(bv); var a = await _http.Update(sendbook); return(RedirectToAction(nameof(Details), new { id = a.Id })); } catch { return(View()); } }
public async Task <ActionResult> Create([FromForm] string title, string ISBN, int year, IEnumerable <string> Authors) { var authors = new List <AuthorView>(); foreach (var id in Authors) { var a = await _httpAuthor.Get(Guid.Parse(id)); var av = Convert(a); if (a != null) { authors.Add(av); } } var bv = new BookView() { Title = title, ISBN = ISBN, Year = year, Authors = authors, }; try { var author = await _http.Create(ConvertBook(bv)); return(RedirectToAction(nameof(Index))); } catch { return(View()); } }
public static void EditBook(BookView book, string[] selectedCourses, BookService db, HttpPostedFileBase Image = null) { if (selectedCourses == null) { selectedCourses = new string[] { }; } if (Image != null) { book.ImageMimeType = Image.ContentType; book.ImageData = new byte[Image.ContentLength]; Image.InputStream.Read(book.ImageData, 0, Image.ContentLength); } WriterService ws = new WriterService(); var selectedCoursesHS = new HashSet <string>(selectedCourses); var allwriter = db.GetAllWriter(); var newwriter = new List <WriterView>(); book.Writers = new List <WriterView>(); foreach (var t in allwriter) { if (selectedCoursesHS.Contains(t.id.ToString())) { book.Writers.Add(t); } } db.Update(book); }
public async Task Setup() { var author = AuthorBuilder.WithLibrary(LibraryId).Build(); var series = SeriesBuilder.WithLibrary(LibraryId).Build(); var categories = CategoryBuilder.WithLibrary(LibraryId).Build(3); var book = new BookView { Title = RandomData.Name, Authors = new List <AuthorView> { new AuthorView { Id = author.Id } }, SeriesId = series.Id, SeriesIndex = 1, SeriesName = series.Name, Language = RandomData.Locale, Categories = RandomData.PickRandom(categories, 2).Select(c => new CategoryView { Id = c.Id }) }; _response = await Client.PostObject($"/libraries/{LibraryId}/books", book); _bookAssert = BookAssert.WithResponse(_response).InLibrary(LibraryId); }
public void BookReceive(string bookName, BookViewModel bookVm, string session) { BookView bookV = (from p in bookDC.BookViews where p.BookName == bookName select p).FirstOrDefault(); Book book = (from p in bookDC.Books where p.BookName == bookName select p).FirstOrDefault(); bookVm.CategoryName = bookV.CategoryName; bookVm.BookName = bookV.BookName; bookVm.AuthorName = bookV.AuthorName; bookVm.PublisherName = bookV.PublisherName; book.BookQuantity--; BookOperation BO = new BookOperation(); Penalty penalty = new Penalty(); BO.UserName = session; BO.ReceivingDate = DateTime.Now; BO.CategoryName = bookVm.CategoryName; BO.BookName = bookVm.BookName; BO.AuthorName = bookVm.AuthorName; BO.PublisherName = bookVm.PublisherName; bookDC.BookOperations.Add(BO); bookDC.SaveChanges(); penalty.BookOperationId = BO.Id; penalty.PenaltyQuantity = 0; bookDC.Penalties.Add(penalty); bookDC.SaveChanges(); }
private void Cancel(object obj) { var book = new BookView(UserId); book.Show(); CloseWindow(); }
/// <summary> /// Generate a new sequence /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void NextRandomSequence(object sender, EventArgs e) { IsUpdatesDXLocked = true; var uiContext = System.Threading.SynchronizationContext.Current; //uiContext.Send(x => BookView.Clear(), null); for (int index = 0; index < LEVELS; index++) { int sequence = random.Next(999); if (BookView.Count <= index) { uiContext.Send(x => BookView.Add(new BookLine { BWork = random.Next(999), Bids = random.Next(50, 1000), Price = random.Next(40000, 90000), Asks = random.Next(50, 1000), AWork = random.Next(999) }), null); } else { uiContext.Send(x => BookView[index] = (new BookLine { BWork = random.Next(999), Bids = random.Next(50, 1000), Price = random.Next(40000, 90000), Asks = random.Next(50, 1000), AWork = random.Next(999) }), null); } } IsUpdatesDXLocked = false; }
/// <summary> /// Shows info about book and gives the user the options to buy or abort. /// </summary> /// <param name="user">Takes a user to be connected to purchase</param> /// <param name="book">Takes a book for obtaining the info shown.</param> internal static void ShowInfoAboutBook(User user, Book book) { var continueLoop = true; do { BookView.ShowInfoAboutBook(book); var input = SharedController.GetSearchInput(); switch (input.ToLower()) { case "j": BuyBook(user, book); continueLoop = false; break; case "n": continueLoop = false; break; default: SharedError.PrintWrongInput(); continueLoop = true; break; } } while (continueLoop); }
public async Task <IActionResult> PutBook([FromRoute] int id, [FromBody] BookView book) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != book.Id) { return(BadRequest()); } var mapperBook = _mapper.Map <Book>(book); _context.Books.Update(mapperBook); try { await _context.Save(); } catch (DbUpdateConcurrencyException) { return(NotFound()); } return(NoContent()); }
public IActionResult DeleteBook(BookView bookView) { Book book = BookViewToBook(bookView); bookContainer.DeleteBook(book); return(RedirectToAction("Index")); }
protected void Page_Load(object sender, EventArgs e) { var chapters = BookChapterView.GetModelList("enable=1 order by UpdateTime desc", 500); var items = new List <Voodoo.other.SEO.RssItem>(); foreach (var chapter in chapters) { items.Add(new Voodoo.other.SEO.RssItem() { Title = chapter.BookTitle + "-" + chapter.Title, PutTime = chapter.UpdateTime, Link = SystemSetting.SiteUrl + GetBookChapterUrl(chapter, BookView.GetClass(chapter)), Description = chapter.BookTitle + "Update to chapter:" + chapter.Title + ", from chanel" + chapter.ClassName }); } var movies = MovieInfoView.GetModelList(); foreach (var m in movies) { items.Add(new Voodoo.other.SEO.RssItem() { Title = m.Title, PutTime = m.UpdateTime, Link = SystemSetting.SiteUrl + GetMovieUrl(m, MovieInfoView.GetClass(m)),// GetBookChapterUrl(chapter, BookView.GetClass(chapter)), Description = m.Title + "Update to :" + m.LastDramaTitle + ", from chanel" + m.ClassName + ", Intro:" + m.Intro }); } Response.Clear(); Voodoo.other.SEO.Rss.GetRss(items, SystemSetting.SiteName, SystemSetting.SiteUrl, SystemSetting.Description, SystemSetting.Copyright); }
// GET: Books/Details/5 public async Task <IActionResult> Details(Guid?id) { if (id == null) { return(NotFound()); } var book = await _addBook.GetBookAsync(id.Value); var bookView = new BookView { Id = book.Id, Author = book.Author, Name = book.Name, Popular = book.Popular, Price = book.Price }; if (book == null) { return(NotFound()); } return(View(bookView)); }
public void ShowBooks() { LibraryController.GetBookList(); List <Object> Result = ParseResult(); bool first = true; foreach (Object V in Result) { if (V.GetType() == typeof(BookView)) { if (first) { BookView V_Converted = (BookView)V; V_Converted.View(); first = false; } else { BookView V_Converted = (BookView)V; V_Converted.View(true, false); } } else { if (V.GetType() == typeof(string)) { Console.WriteLine((string)V); return; } } } }
public override void OpenView () { this.book_view = this.book.GetBookView (BookQuery.AnyFieldContains (""), new object [0], -1); this.book_view.ContactsAdded += OnContactsAdded; this.book_view.ContactsRemoved += OnContactsRemoved; this.book_view.ContactsChanged += OnContactsChanged; this.book_view.SequenceComplete += OnSequenceComplete; this.book_view.Start (); }
public ActionResult ProductDetail(Int32 id) { Book book; BookView bookView; book = (Book)this._bookRepository.FindById(id); bookView = new BookView(book); return View(bookView); }