public string FindTitleBook(string findText) { var Books = _сontext.Books.Include(p => p.author).Where(p => p.Title.ToLower().Contains(findText.ToLower())).ToList <Book>(); string json = JsonSerializer.Serialize(BookDTO.ToListBookDTO(Books)); return(json); }
public string AllBookAuthor(int authorID) { var FindAuthor = _сontext.Authors.Find(authorID); var FindBooks = _сontext.Books.Include(p => p.Genre).Where(p => p.author == FindAuthor).ToList <Book>(); string json = JsonSerializer.Serialize(BookDTO.ToListBookDTO(FindBooks)); return(json); }
public string FindBooks(int year, bool sort) { List <Book> Books; if (sort != false) { Books = _сontext.Books.Where(p => p.DateWrite.Year == year).OrderByDescending(p => p.Title).ToList <Book>(); } else { Books = _сontext.Books.Where(p => p.DateWrite.Year == year).OrderBy(p => p.Title).ToList <Book>(); } string json = JsonSerializer.Serialize(BookDTO.ToListBookDTO(Books)); return(json); }