public static void DoSearchByTitle(IEnumerable <Book> books) { DoSearch( searchPrompt: "Search by book title or a part of it.", searchFunc: searchTerm => Search.ByTitle(books, searchTerm) .Select(b => BookMap.AuthorAndTitle(b))); }
protected override void OnModelCreating(DbModelBuilder modelBuilder) { BookMap.Map(modelBuilder.Entity <Book>()); AuthorMap.Map(modelBuilder.Entity <Author>()); GenreMap.Map(modelBuilder.Entity <Genre>()); StatusMap.Map(modelBuilder.Entity <Status>()); }
private static void DoSearchByCategory(IEnumerable <Book> books) { DoSearch("Search by book category or a part of it. \n" + "(for example: fic or Fiction or aut or bio or autobiography) \n" + "comma separated lists acceptable : juv, sci", searchTerm => books .SearchByCategories(searchTerm.FromCommaSeparatedList()) .Select(b => BookMap.CategoryAuthorAndTitle(b)) .Highlight(searchTerm.FromCommaSeparatedList()) ); }
public bool Add(ICRUDableEntity Entity) { var mapper = BookMap.InitializeMapper(); var bookDTO = mapper.Map <Models.Books>(Entity); using (var context = new BookStoreContext()) { context.Books.Add(bookDTO); context.SaveChanges(); } return(true); }
/// <summary> /// 保存用户教学地图数据 /// </summary> /// <param name="request"></param> /// <returns></returns> private SyncResponse SaveUserTeachMap(SyncRequest request) { BookMap submitData = JsonHelper.DecodeJson <BookMap>(request.Data); UserInfo userData = JsonHelper.DecodeJson <UserInfo>(request.Data); if (userData.Type == 4)//管理员 { HttpClient myHttpClient = new HttpClient(); myHttpClient.BaseAddress = new Uri(webapi_url); //webapi_url string json = JsonHelper.DeepEncodeJson(submitData); var content = new StringContent(json, Encoding.UTF8); content.Headers.ContentType = new MediaTypeHeaderValue("application/json"); HttpResponseMessage response = myHttpClient.PostAsync("GetTextBookMap", content).Result; return(SyncResponse.GetResponse(request, response.IsSuccessStatusCode)); } else { using (var db = new fz_wisdomcampusEntities()) { var map = db.clr_teachmap.FirstOrDefault(m => m.UserID == userData.UserID && m.BookID == submitData.bookId && m.UnitID == submitData.unitId); if (map != null) { map.Map = submitData.MapContent; map.CreateTime = DateTime.Now; db.SaveChanges(); } else { clr_teachmap model = new clr_teachmap(); model.ID = Guid.NewGuid(); model.UserID = userData.UserID; model.BookID = submitData.bookId; model.UnitID = submitData.unitId; model.Map = submitData.MapContent; model.CreateTime = DateTime.Now; db.clr_teachmap.Add(model); db.SaveChanges(); } } return(SyncResponse.GetResponse(request, true)); } }
//TODO: Tab targeting is not working this requires work on Shared _QuizzesTabHelper. public async Task <IActionResult> OnGetAsync(string BibleId, string Message, string Tab = "Quizzes") { IdentityUser user = await _userManager.GetUserAsync(User); PBEUser = await QuizUser.GetOrAddPBEUserAsync(_context, user.Email); // Static method not requiring an instance this.BibleId = await Bible.GetValidPBEBibleIdAsync(_context, BibleId); Templates = await _context.PredefinedQuizzes.Where(T => T.IsDeleted == false && T.QuizUser == PBEUser) .OrderByDescending(T => T.Created) .ToListAsync(); BookLists = await _context.QuizBookLists.Include(L => L.QuizBookListBookMaps) .Where(L => L.IsDeleted == false) .OrderByDescending(L => L.Created) .ToListAsync(); foreach (QuizBookList BookList in BookLists) { foreach (QuizBookListBookMap BookMap in BookList.QuizBookListBookMaps) { _ = await BookMap.AddBookNameAsync(_context, this.BibleId); } } Quizzes = await _context.QuizGroupStats.Where(G => G.QuizUser == PBEUser && G.IsDeleted == false) .OrderByDescending(Q => Q.Modified) .ToListAsync(); //TODO: Tab targeting is not working this requires work on Shared _QuizzesTabHelper. InitialTab = Tab; // Populate Quiz Info foreach (QuizGroupStat quiz in Quizzes) { _ = await quiz.AddQuizPropertiesAsync(_context, this.BibleId); } UserMessage = GetUserMessage(Message); return(Page()); }
public async Task <IActionResult> OnGetAsync(string BibleId, string Message) { IdentityUser user = await _userManager.GetUserAsync(User); PBEUser = await QuizUser.GetOrAddPBEUserAsync(_context, user.Email); // Static method not requiring an instance this.BibleId = await Bible.GetValidPBEBibleIdAsync(_context, BibleId); BookLists = await _context.QuizBookLists.Include(L => L.QuizBookListBookMaps) .Where(L => L.IsDeleted == false) .ToListAsync(); foreach (QuizBookList BookList in BookLists) { foreach (QuizBookListBookMap BookMap in BookList.QuizBookListBookMaps) { _ = await BookMap.AddBookNameAsync(_context, this.BibleId); } } UserMessage = GetUserMessage(Message); return(Page()); }
protected override void OnModelCreating(ModelBuilder modelBuilder) { var bookMap = new BookMap(modelBuilder.Entity <Book>()); base.OnModelCreating(modelBuilder); }
static void Main(string[] args) { BookMap.create_replay(); Console.Read(); }
public static void Main() { IBooksSource BooksSource = new BooksJsonSource(); Book selected = Book.Empty; var books = BooksSource.Read(); while (true) { Console.WriteLine(selected == Book.Empty ? "No book selected" : $"Selected: {BookMap.CategoryAuthorAndTitle(selected)}"); Console.WriteLine("\nActions available:"); Console.WriteLine("1 - Output all books by author (Section 2)"); Console.WriteLine("2 - Search books by title (Section 3)"); Console.WriteLine("3 - Search books by category (Section 4)"); Console.WriteLine("4 - Select a book(Section 5)"); if (selected != Book.Empty) { Console.WriteLine($"5 - Recommend similar to {selected.title} (Section 5)"); Console.WriteLine($"6 - Delete {selected.title} (Section 6)"); } Console.WriteLine("7 - Add a book (Section 6)"); Console.WriteLine("Any other key - Exit"); var key = Console.ReadKey(); Console.WriteLine(); switch (key.KeyChar) { case '1': Output.BooksByAuthor(books, Console.Write); break; case '2': DoSearchByTitle(books); break; case '3': DoSearchByCategory(books); break; case '4': selected = DoSelect(books); break; case '5': DoRecommend(books, selected); break; case '6': { BooksSource.Delete(selected); selected = Book.Empty; books = BooksSource.Read(); break; } case '7': { Add.Book( prompt: s => { Console.WriteLine(s); return(Console.ReadLine()); }, add: BooksSource.Add ); // update books books = BooksSource.Read(); break; } default: return; } } }