public void Execute(AppointmentStarted @event) { Printer.Print(ConsoleColor.Magenta); var appointmentRepository = new MyRepository <Appointment>(); var appointment = appointmentRepository.Fetch(@event.AppointmentId); var jobRepository = new MyRepository <Job>(); var job = jobRepository.Fetch(appointment.JobId); job.Start(); //Printer.Print("Job marked as in progress", ConsoleColor.Magenta); }
public void Start() { Printer.Print(ConsoleColor.Cyan); if (Status == Status.Canceled) { throw new Exception("Appointment is cancelled, can not mark it in progress"); } var @event = new AppointmentStarted(Id); Apply(@event); DomainEvents.Publish(@event); }
public void Apply(AppointmentStarted @event) { Status = Status.InProgress; }