public ActionResult <BookRead> Add(BookCreating create) { var book = _mapper.Map <Book>(create); var ok = _repo.Add(book); _repo.SaveChages(); return(Ok(_mapper.Map <BookRead>(_repo.First(book.Id)))); }
public IActionResult Create(Book book) { if (ModelState.IsValid) { _bookrepository.Add(book); return(View("GetUpdatedList", _bookrepository.Database)); } else { return(View()); } }
public ActionResult Create(Author author) { try { authorRepos.Add(author); return(RedirectToAction(nameof(Index))); } catch { return(View()); } }
public async Task NewBook(string name, int authorId) { var author = await _repo.GetAsync(authorId); if (author == null) { throw new Exception($"No Authors Found"); } var newBook = Book.Create(name, author); _repoForBook.Add(newBook); await _unitOfWork.CompleteAsync(); }
public ActionResult Create(Book newBook, IFormCollection collection) { try { // TODO: Add insert logic here if (ModelState.IsValid) { _bookRepo.Add(newBook); } return(RedirectToAction(nameof(Index))); } catch { return(View(newBook)); } }
public ActionResult Create(BookAuthorViewModel model) { try { Book book = new Book { Id = model.Id, Title = model.Title, Description = model.Description, Author = authorRepository.Find(model.AuthorId) }; bookrepositry.Add(book); return(RedirectToAction(nameof(Index))); } catch { return(View()); } }
public Book PostBook(Book book) { book = bookRepository.Add(book); return(book); }
public Book Add(Book book) { return(_bookRepo.Add(book)); }
public Guid Add(Book book) { return(_bookRepo.Add(book)); }