public void Add(BookDetails newBook) { var query = string.Format(@"INSERT INTO BookDetails (Title, Author) VALUES ('{0}','{1}')", newBook.Title, newBook.Author); using (var con = new SqlConnection(_connectionStringSettings.ToString())) { con.Open(); using (var command = new SqlCommand(query, con)) command.ExecuteNonQuery(); } }
public void Add(BookDetails newBook) { if (newBook == null) { throw new ArgumentNullException("Parameter newBook can't be null."); } newBook.Id = _nextId; _book.Add(newBook); _nextId++; }
public ActionResult Create(BookDetails newBook) { _bookRepository.Add(newBook); TempData["Message"] = "The book has been added to repository."; return this.RedirectToAction(c=>c.Index()); }