コード例 #1
0
        public ActionResult Create(BookViewModel book)
        {
            var bookDomain = Mapper.Map <BookViewModel, Book>(book);

            _bookApp.Add(bookDomain);

            return(Json("Success", JsonRequestBehavior.DenyGet));
        }
コード例 #2
0
        public ActionResult Create(BookViewModel book)
        {
            if (ModelState.IsValid)
            {
                var bookDomain = Mapper.Map <BookViewModel, Book>(book);
                _bookApp.Add(bookDomain);

                return(RedirectToAction("Index"));
            }
            return(View(book));
        }
コード例 #3
0
        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));
        }
コード例 #4
0
        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));
        }
コード例 #5
0
        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);
        }
コード例 #6
0
 public IActionResult Post([FromBody] BookModel book)
 {
     return(new ObjectResult(_bookAppService.Add(book)));
 }