private void patronymicLinkLabel_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { ReaderRepository readerRepository = new ReaderRepository(); LinkLabel thisLinkLabel = (sender as LinkLabel); var readers = readerRepository.Get().Select(r => new { r.Id, r.Name, r.Surname, r.Patronymic, r.DateOfBirth, r.TelephoneNumber, r.Email }); if (thisLinkLabel.Text.Contains("˄")) { readerDataGridView.DataSource = readers.OrderBy(r => r.Patronymic).ToList(); thisLinkLabel.Text = thisLinkLabel.Text.Split('˄')[0] + "˅"; } else { readerDataGridView.DataSource = readers.OrderByDescending(r => r.Patronymic).ToList(); thisLinkLabel.Text = thisLinkLabel.Text.Split('˅')[0] + "˄"; } }
private void SetDataGridView() { var readerRepository = new ReaderRepository(); readerDataGridView.DataSource = readerRepository.Get() .OrderBy(b => b.Id) .Select(b => new { b.Id, b.Name, b.Surname, b.Patronymic, b.DateOfBirth, b.TelephoneNumber, b.Email }).ToList(); }
public void SetDataGridView() { var readerRepository = new ReaderRepository(); var readers = from reader in readerRepository.Get() select new { Id = reader.Id, Name = reader.Name, Surname = reader.Surname, Patronymic = reader.Patronymic, DateOfBirth = reader.DateOfBirth, TelephoneNumber = reader.TelephoneNumber, Email = reader.Email }; this.dataGridView1.DataSource = readers.ToList(); }
public Reader GetReader(int id) { return(readersRepo.Get(id)); }
public MainViewController(DbContext dbContext) { booksRepo = new BookRepository(dbContext); readersRepo = new ReaderRepository(dbContext); authorsRepo = new AuthorRepository(dbContext); CommandsHandler = new Dictionary <string, Func <MainViewArgs, object> > { #region booksCRUD { "get_books", x => { string res = ""; foreach (var book in booksRepo.GetAll()) { res += (book.ToString() + "\n"); } return(res); } }, { "get_book", x => { return(booksRepo.Get(x.BookId).ToString()); } }, { "delete_book", x => { booksRepo.Remove(x.BookId); return(okMessage); } }, { "insert_book", x => { booksRepo.CreateOrUpdate(x.Book); return(okMessage); } }, { "update_book", x => { booksRepo.CreateOrUpdate(x.Book); return(okMessage); } }, #endregion #region booksAuthors { "AddAuthorToBook", x => { booksRepo.Get(x.BookId).Authors.Add(authorsRepo.Get(x.AuthorId)); return(okMessage); } }, { "DeleteAuthorFromBook", x => { booksRepo.Get(x.BookId).Authors.Remove(authorsRepo.Get(x.AuthorId)); return(okMessage); } }, { "GetAuthorsOfBook", x => { string res = ""; foreach (var author in booksRepo.Get(x.BookId).Authors) { res += (author.ToString() + "\n"); } return(res); } }, #endregion #region booksReaders { "AddReaderToBook", x => { booksRepo.Get(x.BookId).Readers.Add(readersRepo.Get(x.ReaderId)); return(okMessage); } }, { "DeleteReaderFromBook", x => { booksRepo.Get(x.BookId).Readers.Remove(readersRepo.Get(x.ReaderId)); return(okMessage); } }, { "GetReadersOfBook", x => { string res = ""; foreach (var reader in booksRepo.Get(x.BookId).Readers) { res += (reader.ToString() + "\n"); } return(res); } }, #endregion #region authorsCRUD { "get_authors", x => { string res = ""; foreach (var author in authorsRepo.GetAll()) { res += (author.ToString() + "\n"); } return(res); } }, { "get_author", x => { return(authorsRepo.Get(x.AuthorId).ToString()); } }, { "delete_author", x => { authorsRepo.Remove(x.AuthorId); return(okMessage); } }, { "insert_author", x => { authorsRepo.CreateOrUpdate(x.Author); return(okMessage); } }, { "update_author", x => { authorsRepo.CreateOrUpdate(x.Author); return(okMessage); } }, { "get_authorsbooks", x => { string res = ""; foreach (var book in authorsRepo.Get(x.AuthorId).Books) { res += (book.ToString() + "\n"); } return(res); } }, #endregion #region readersCRUD { "get_readers", x => { string res = ""; foreach (var reader in readersRepo.GetAll()) { res += (reader.ToString() + "\n"); } return(res); } }, { "get_reader", x => { return(readersRepo.Get(x.ReaderId).ToString()); } }, { "delete_reader", x => { readersRepo.Remove(x.ReaderId); return(okMessage); } }, { "insert_reader", x => { readersRepo.CreateOrUpdate(x.Reader); return(okMessage); } }, { "update_reader", x => { readersRepo.CreateOrUpdate(x.Reader); return(okMessage); } }, { "get_readersbooks", x => { string res = ""; foreach (var book in readersRepo.Get(x.ReaderId).Books) { res += (book.ToString() + "\n"); } return(res); } }, #endregion { "add_random_authors", x => { return(GetBooLReturnMessage(authorsRepo.AddRandomAuthorsToDB(x.RandomCount))); } }, { "search_books", x => { string res = ""; foreach (var book in booksRepo.SearchBooks(x.SearchBookParameters.title, x.SearchBookParameters.minPagesCount, x.SearchBookParameters.maxPagesCount)) { res += (book.ToString() + "\n"); } return(res); } }, { "search_authors", x => { string res = ""; foreach (var author in authorsRepo.SearchAuthors(x.SearchAuthorParameters.Signature, x.SearchAuthorParameters.Name, x.SearchAuthorParameters.MinDate)) { res += (author.ToString() + "\n"); } return(res); } }, { "search_readers", x => { string res = ""; foreach (var reader in readersRepo.SearchReaders(x.SearchReaderParameters.Favouritegenre, x.SearchReaderParameters.Name, x.SearchReaderParameters.Surname)) { res += (reader.ToString() + "\n"); } return(res); } }, }; }