コード例 #1
0
        public async Task <ActionResult <Book> > Post([FromBody] Book book)
        {
            //book.ISBN =(int) await _repo.GetNextId();
            await _repo.Create(book);

            return(new OkObjectResult(book));
        }
コード例 #2
0
        public void Insert(BookModel book)
        {
            _repository.Create(new Book
            {
                Title  = book.Title,
                Author = book.Author
            });

            RedirectToAction("Index");
        }
コード例 #3
0
        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));
        }
コード例 #4
0
        public async Task CreateWithoutPathTest()
        {
            Library library = TestSample.GetNew <Library>();

            library.Paths = null;
            await Assert.ThrowsAsync <ArgumentException>(() => _repository.Create(library));
        }
コード例 #5
0
        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"));
        }
コード例 #6
0
 public IActionResult Create(LibraryViewModel libraryViewModel)
 {
     _libraryRepository.Create(libraryViewModel.Library);
     return(RedirectToAction("Index"));
 }