public async Task <ActionResult <Book> > Post([FromBody] Book book) { //book.ISBN =(int) await _repo.GetNextId(); await _repo.Create(book); return(new OkObjectResult(book)); }
public void Insert(BookModel book) { _repository.Create(new Book { Title = book.Title, Author = book.Author }); RedirectToAction("Index"); }
public async Task <IActionResult> PostLibrary([FromBody] LibraryDto dto) { var dbLibrary = dto.ToDbModel(); var created = await _libraryRepository.Create(Guid.NewGuid(), dbLibrary.Name, dbLibrary.Address); var createdDto = created.ToDto(); return(Created($"/{createdDto.Id}", createdDto)); }
public async Task CreateWithoutPathTest() { Library library = TestSample.GetNew <Library>(); library.Paths = null; await Assert.ThrowsAsync <ArgumentException>(() => _repository.Create(library)); }
public ActionResult Insert(BookModel book) { _repository.Create(new Book { Title = book.Title, Author = new Author { Name = book.Author.Name, Surname = book.Author.Surname } }); return(RedirectToAction("Index")); }
public IActionResult Create(LibraryViewModel libraryViewModel) { _libraryRepository.Create(libraryViewModel.Library); return(RedirectToAction("Index")); }