Пример #1
0
        public void Should_Return_If_Validation_For_Not_Existing_Book_Fails()
        {
            var bookMobileGetDto = new BookMobileGetDto
            {
                Code           = "0",
                OfficeId       = 1,
                OrganizationId = 1
            };

            Assert.ThrowsAsync <BookException>(async() => await _bookService.GetBookAsync(bookMobileGetDto));
        }
Пример #2
0
        public async Task <IHttpActionResult> GetBook([FromUri] BookMobileGetViewModel bookViewModel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var bookDto = _mapper.Map <BookMobileGetViewModel, BookMobileGetDto>(bookViewModel);

            try
            {
                var getBookDto = await _bookMobileService.GetBookAsync(bookDto);

                var getBookViewModel = _mapper.Map <RetrievedBookInfoDto, RetrievedMobileBookInfoViewModel>(getBookDto);
                return(Ok(getBookViewModel));
            }
            catch (BookException ex)
            {
                return(BadRequest(ex.Message));
            }
        }