private void btnAddFavs_Click(object sender, EventArgs e) { book = new BookDTO(); foreach (DataGridViewRow row in dgvBooks.SelectedRows) { book.BookName = row.Cells[0].Value.ToString(); book.AuthorName = row.Cells[1].Value.ToString(); book.PublisherName = row.Cells[2].Value.ToString(); book.PublishingYear = (int)row.Cells[3].Value; book.PageCount = (int)row.Cells[4].Value; book.Summary = row.Cells[5].Value.ToString(); book.Price = (decimal)row.Cells[6].Value; book.IsAvailable = (bool)row.Cells[7].Value; } selectedBooks.Add(book); int bookID = _bookController.GetBookIDByName(book.BookName, book.AuthorName); favBook = new FavoriteDTO(); favBook.BookID = bookID; favBook.UserID = user.UserID; try { bool result = _bookController.AddFavs(favBook); if (result) { MessageBox.Show("Kayıt başarılı"); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }