Beispiel #1
0
        public ActionResult Create(CreateBookViewModel model)
        {
            var book = mapper.Map <CreateBookViewModel, Book>(model);

            try
            {
                if (ModelState.IsValid)
                {
                    if (books.Add(book))
                    {
                        return(RedirectToAction("Index"));
                    }
                }
                model = new CreateBookViewModel(authors, cities, publishings);
                return(View(model));
            }
            catch
            {
                model = new CreateBookViewModel(authors, cities, publishings);
                return(View(model));
            }
        }
Beispiel #2
0
        public async Task <IActionResult> Add(Book book)
        {
            await _bookLogic.Add(book);

            return(Ok("Added"));
        }
Beispiel #3
0
 public static void AddBook(Book book, IBookLogic bookLogic)
 {
     bookLogic.Add(book);
 }