Пример #1
0
        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))));
        }
Пример #2
0
 public IActionResult Create(Book book)
 {
     if (ModelState.IsValid)
     {
         _bookrepository.Add(book);
         return(View("GetUpdatedList", _bookrepository.Database));
     }
     else
     {
         return(View());
     }
 }
Пример #3
0
 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();
        }
Пример #5
0
        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));
            }
        }
Пример #6
0
 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());
     }
 }
Пример #7
0
 public Book PostBook(Book book)
 {
     book = bookRepository.Add(book);
     return(book);
 }
Пример #8
0
 public Book Add(Book book)
 {
     return(_bookRepo.Add(book));
 }
Пример #9
0
 public Guid Add(Book book)
 {
     return(_bookRepo.Add(book));
 }