Slide 40
Slide 40 text
Dispatching the command
/** @Route("/campaigns", methods={"POST"}) */
public function createCampaignAction(CreateCampaignDto $dto)
{
$campaignId = Webshop\CampaignId::generate();
$this->commandBus->dispatch(new CreateCampaignForTargetGroup(
$campaignId,
$this->companyId,
$this->accountId,
TargetGroup::describe(
TargetGroup\JobTitle::fromString($dto->title),
TargetGroup\Region::fromId($dto->region),
TargetGroup\JobCategory::fromId($dto->jobCategory),
TargetGroup\EducationLevel::fromId($dto->educationLevel),
TargetGroup\JobLevel::fromId($dto->jobLevel),
TargetGroup\Industry::fromId($dto->industry)
)
));
return new JsonResponse(
['id' => (string) $campaignId], JsonResponse::HTTP_CREATED
);
}