private void Button2_Click(object sender, EventArgs e) { Book newBook = new Book { Name = textBox1.Text }; List <Author> authors = new List <Author>(); foreach (var item in listBox1.SelectedItems) { authors.Add(AuthorHelper.MapAuthorModel((AuthorModel)item)); } newBook.Authors = authors; List <Genre> genres = new List <Genre>(); foreach (var item in listBox2.SelectedItems) { genres.Add(GenreHelper.MapGenreModel((GenreModel)(item))); } newBook.Genres = genres; newBook.PageCount = Convert.ToInt32(textBox2.Text); bool isAdded = BookHelper.Addbook(newBook); if (isAdded) { this.LoadBooks(); } }