public function handle(DeleteTask $command)
 {
     $taskDescription = new TaskDescription($command->getDescription());
     $workingDay = $this->repo->getByDate(Carbon::now());
     $workingDay->deleteTaskWithDescription($taskDescription);
     $this->repo->add($workingDay);
 }
 public function testICanDeleteTaskFromTheWorkingDayFromCommand()
 {
     $workingDay = new WorkingDay(WorkingDayId::generate());
     $workingDay->addTask(new Task("Task test"));
     $this->workingDayRepo->add($workingDay);
     $this->commandHandler->handle(new DeleteTask("Task test"));
     $this->assertCount(0, $workingDay->getTasks());
 }
 public function handle(SendReport $command)
 {
     $workingDay = $this->repo->getByDate(Carbon::today());
     if (!$workingDay) {
         throw new EmptyWorkingDayException();
     }
     $this->mailProvider->sendReportOf($workingDay);
 }
예제 #4
0
 public function handle(ListTasks $command)
 {
     $workingDay = $this->repo->getByDate(Carbon::now());
     $tasks = $workingDay->getTasks();
     foreach ($tasks as $task) {
         print_r($tasks);
     }
 }
예제 #5
0
 /**
  * @return \Doctrine\Common\Collections\ArrayCollection
  * @throws EmptyWorkingDayException
  */
 public function handle()
 {
     $workingDay = $this->repo->getByDate(Carbon::now());
     if (!$workingDay || $workingDay->getTasks()->isEmpty()) {
         throw new EmptyWorkingDayException();
     }
     $tasks = $workingDay->getTasks();
     return $tasks;
 }