-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathBackLogController.php
79 lines (62 loc) · 2.43 KB
/
BackLogController.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<?php
namespace App\Http\Controllers;
use App\Http\ViewModels\BackLog\BackLogIndexViewModel;
use App\Http\ViewModels\BackLog\UserStoryViewModel;
use Basic\Exception\NotFoundException;
use Illuminate\Http\Request;
use Scrum\Application\Service\BackLog\AddUserStoryCommand;
use Scrum\Application\Service\BackLog\BackLogApplicationService;
use Scrum\Application\Service\BackLog\Query\BackLogQueryServiceInterface;
use Scrum\Application\Service\BackLog\Query\UserStorySummary;
class BackLogController extends Controller
{
public function index(BackLogQueryServiceInterface $backLogQueryService)
{
$userStories = $backLogQueryService->getAllUserStory();
$userStoriesViewModels = collect($userStories)->map(function (UserStorySummary $summary) {
return new UserStoryViewModel(
$summary->id,
$summary->story,
$summary->author,
$summary->demo,
$summary->estimation
);
})->all();
$viewModel = new BackLogIndexViewModel($userStoriesViewModels);
return view("backlog/index", compact("viewModel"));
}
public function getUserStory(string $id, BackLogApplicationService $applicationService)
{
$story = $applicationService->getUserStory($id);
if (is_null($story)) {
throw new NotFoundException($id . " is notfound.");
}
$viewModel = new UserStoryViewModel(
$story->getId()->getValue(),
$story->getStory(),
$story->getAuthor()->getValue(),
$story->getDemo(),
$story->getEstimation()
);
return view("backlog/user-story/index", compact("viewModel"));
}
public function getAddUserStory()
{
return view("backlog/add-user-story");
}
public function postAddUserStory(Request $request, BackLogApplicationService $applicationService)
{
$request->validate([
"story" => "required"
]);
$story = $request->input("story");
$command = new AddUserStoryCommand($story);
$applicationService->addUserStory($command);
return redirect()->action([BackLogController::class, "index"]);
}
public function estimateUserStory(string $id, Request $request, BackLogApplicationService $applicationService)
{
$estimation = $request->get("estimation");
$applicationService->estimateUserStory($id, $estimation);
}
}