/**
  * @Rest\Post("",
  *  condition="request.headers.get('content-type') matches '/domain-model=add-book/i'"
  * )
  * @Rest\View(statusCode=201)
  *
  * @ParamConverter("bookResource",
  *  class="AppBundle\Controller\Resource\Book",
  *  converter="fos_rest.request_body"
  * )
  *
  * @param BookResource $bookResource
  * @return View
  * @throws HttpException
  */
 public function addBookAction(BookResource $bookResource)
 {
     $id = Uuid::createNew();
     $authors = array_map(function (AuthorResource $author) use($id) {
         return new AddAuthor($id, $author->getFirstName(), $author->getLastName(), -1);
     }, $bookResource->getAuthors());
     $command = new AddBook($id, $authors, $bookResource->getTitle(), $bookResource->getISBN());
     $this->commandBus->send($command);
     $book = $this->bookService->getBook($id);
     return $this->viewBuilder->setDocument($book)->setVersion()->setLocation(static::BASE_ROUTE . $book->getId())->build();
 }
 /**
  * @Rest\Put("",
  *  condition="request.headers.get('content-type') matches '/domain-model=create-user/i'"
  * )
  * @Rest\View()
  *
  * @ParamConverter("userResource",
  *  class="AppBundle\Controller\Resource\User",
  *  converter="fos_rest.request_body"
  * )
  *
  * @param UserResource $userResource
  * @return View
  * @throws HttpException
  */
 public function createAction(UserResource $userResource)
 {
     $user = $this->userService->getUserByUserName($userResource->getUserName());
     if ($user != null) {
         return $this->viewBuilder->setStatus(204)->setVersion($user)->setLocation(static::BASE_ROUTE . $user->getId())->build();
     }
     $id = Uuid::createNew();
     $command = new CreateUser($id, $userResource->getUserName(), $userResource->getEmailAddress(), $userResource->getFullName());
     $this->commandBus->send($command);
     $user = $this->userService->getUser($id);
     return $this->viewBuilder->setDocument($user)->setVersion()->setLocation(static::BASE_ROUTE . $user->getId())->setStatus(201)->build();
 }