コード例 #1
0
        public void Handle(AppointmentScheduled @event)
        {
            if (@event.From != null && @event.To != null)
            {
                TimeSlot = new TimeSlot(@event.From.Value, @event.To.Value);
            }

            Id            = @event.AppointmentId;
            JobId         = @event.JobId;
            StaffMemberId = @event.StaffMemberId;
            Status        = Status.Initiated;
        }
コード例 #2
0
ファイル: Job.cs プロジェクト: tedmax100/PracticalDDD
        public void Execute(AppointmentScheduled @event)
        {
            Printer.Print("Updating JobView in effect of AppointmentScheduled event", ConsoleColor.Magenta);

            var staffRepository = new MyRepository <StaffMember>();
            var staff           = @event.StaffMemberId.HasValue ? staffRepository.Fetch(@event.StaffMemberId.Value) : null;

            var jobViewRepository = new MyRepository <JobView>();
            var jobView           = jobViewRepository.Fetch(@event.JobId);

            jobView.Appointments.Add(new AppointmentView
            {
                Id         = @event.AppointmentId,
                AssignedTo = staff == null ? null : staff.Name,
                From       = @event.From,
                To         = @event.To
            });

            jobViewRepository.Update(jobView);

            Publish(jobView);
        }