public ActionResult Create(BookViewModel book) { var bookDomain = Mapper.Map <BookViewModel, Book>(book); _bookApp.Add(bookDomain); return(Json("Success", JsonRequestBehavior.DenyGet)); }
public ActionResult Create(BookViewModel book) { if (ModelState.IsValid) { var bookDomain = Mapper.Map <BookViewModel, Book>(book); _bookApp.Add(bookDomain); return(RedirectToAction("Index")); } return(View(book)); }
public IActionResult Post([FromBody] RegisterBookViewModel bookViewModel) { var book = _mapper.Map <Book>(bookViewModel); if (book.Invalid) { return(BadRequest(book.Notifications)); } _bookAppService.Add(book); return(Ok(bookViewModel)); }
public IActionResult Create(BookViewModel bookViewModel) { if (!ModelState.IsValid) { return(View(bookViewModel)); } var bookViewModelResult = _bookAppService.Add(bookViewModel); if (bookViewModelResult?.Data == null) { return(NotFound()); } return(View(bookViewModelResult.Data)); }
public ResponseBase Add(Book book) { ResponseBase response = new ResponseBase(); try { response.Success = _appService.Add(book); } catch (LibraryException ex) { response.Message = ex.Message; } catch (Exception ex) { throw ex; } return(response); }
public IActionResult Post([FromBody] BookModel book) { return(new ObjectResult(_bookAppService.Add(book))); }