/// <summary> /// Retrieves list of Chapter objects from SqlCommand, after database query /// number of rows retrieved and returned depends upon the rows field value /// </summary> /// <param name="cmd">The command object to use for query</param> /// <param name="rows">Number of rows to process</param> /// <returns>A list of Chapter objects</returns> private ChapterList GetList(SqlCommand cmd, long rows) { // Select multiple records SqlDataReader reader; long result = SelectRecords(cmd, out reader); //Chapter list ChapterList list = new ChapterList(); using ( reader ) { // Read rows until end of result or number of rows specified is reached while (reader.Read() && rows-- != 0) { Chapter chapterObject = new Chapter(); FillObject(chapterObject, reader); list.Add(chapterObject); } // Close the reader in order to receive output parameters // Output parameters are not available until reader is closed. reader.Close(); } return(list); }
private void _loadChapter() { ChapterList.Clear(); SqlHelper.Conn.Open(); using (var reader = SqlHelper.Select <BookChapter>("Id, BookId, Name, Position, Url", "WHERE BookId = @id ORDER BY Position ASC, Id ASC", new SqliteParameter("@id", Book.Id))) { while (reader.Read()) { if (reader.HasRows) { ChapterList.Add(new BookChapter(reader)); } } } SqlHelper.Conn.Close(); }
public void ImportMangaInfo() { Url = savedinfo.url; Name = savedinfo.name; Description = savedinfo.description; ImageSource = savedinfo.image?.ToFreezedBitmapImage(); IsFavourite = savedinfo.isFavourite; IsCompleted = savedinfo.isCompleted; Dispatcher dispatcher; if (Dispatcher.CurrentDispatcher != Application.Current.Dispatcher) { dispatcher = Application.Current.Dispatcher; } else { dispatcher = Dispatcher.CurrentDispatcher; } dispatcher.Invoke(() => { AuthorList = savedinfo.authors; GenreList.Clear(); for (int i = 0; i < savedinfo.genres.Count; i++) { GenreList.Add(new GenreItemViewModel { Text = savedinfo.genres[i] }); } ChapterList.Clear(); for (int i = 0; i < savedinfo.chapters.Count; i++) { ChapterListItemViewModel model = new ChapterListItemViewModel(this, i) { Name = savedinfo.chapters[i], URL = savedinfo.chapterUrls[i] }; model.CheckIfDownloaded(); ChapterList.Add(model); } }); }
private void LoadData(Volume volume) { IsLoading = true; Id = volume.Id; Title = volume.Title; Author = volume.Author; Description = volume.Description; CoverImageUri = new Uri(volume.CoverImageUri); ChapterList.Clear(); foreach (var cp in volume.Chapters) { var cpvm = new ChapterPreviewModel { Id = cp.Id, No = cp.ChapterNo, Title = cp.Title, }; ChapterList.Add(cpvm); } IsLoading = false; }