public async Task Handle(LeaveInCommand command) { School school = await schoolRepository.GetSchool(command.SchooId); Parent parent = await schoolRepository.GetParent(command.SchooId, command.Header.UserId); Child child = await schoolRepository.GetChild(command.SchooId, command.ChildId); school.Leave(parent, child); await bus.Publish(school.GetEvents(), command.Header); }
public async Task <Child> Handle(AddChildCommand command) { School school = await schoolRepository.GetSchool(command.SchoolId); Parent parent = await schoolRepository.GetParent(command.SchoolId, command.ParentId); Child child = Child.Create( Name.Create(command.Name), BirthDate.Create(command.BirthDate), Custody.Create(CustodyEnum.ChildConfirmedWithFamily)); school.AddChild(parent, child); await bus.Publish(school.GetEvents(), command.Header); return(child); }