コード例 #1
0
        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 void Handle(ChildCheckedOutDomainEvent domainEvent)
        {
            School school = schoolReadOnlyRepository.GetSchool(domainEvent.AggregateRootId).Result;

            if (school.Version != domainEvent.Version)
            {
                throw new TransactionConflictException(school, domainEvent);
            }

            school.Apply(domainEvent);
            schoolWriteOnlyRepository.UpdateSchool(school).Wait();
        }
コード例 #3
0
        public async Task Handle(CheckInCommand command)
        {
            School school = await schoolRepository.GetSchool(command.SchoolId);

            Teacher teacher = await schoolRepository.GetTeacher(command.SchoolId, command.Header.UserId);

            Child child = await schoolRepository.GetChild(command.SchoolId, command.ChildId);

            school.CheckIn(teacher, child);

            await bus.Publish(school.GetEvents(), command.Header);
        }
コード例 #4
0
        public async Task <Teacher> Handle(AddTeacherCommand command)
        {
            School school = await schoolRepository.GetSchool(command.SchoolId);

            Teacher teacher = Teacher.Create(Name.Create(command.Name));

            school.AddTeacher(teacher);

            await bus.Publish(school.GetEvents(), command.Header);

            return(teacher);
        }
コード例 #5
0
        public async Task <Parent> Handle(AddParentCommand command)
        {
            School school = await schoolRepository.GetSchool(command.SchoolId);

            Parent parent = Parent.Create(
                Name.Create(command.Name),
                Identification.Create(command.Identification),
                BirthDate.Create(command.BirthDate));

            school.AddParent(parent);

            await bus.Publish(school.GetEvents(), command.Header);

            return(parent);
        }
コード例 #6
0
        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);
        }