class ReserveRoomCommandHandler(CommandHandler): def __init__(self): self.factory = AggregateFactory() self.event_store_client = EventStoreClient() self.aggregate_type = type(Reservation()) def Send(self, command: MakeReservation): reservation_id = command.Id reservation = self.factory.get(self.aggregate_type, reservation_id) events = reservation.Reserve(command) self.event_store_client.Save(reservation) return events
class RemoveReservationCommandHandler(CommandHandler): def __init__(self): self.factory = AggregateFactory() self.event_store_client = EventStoreClient() self.aggregate_type = type(Reservation()) def Publish(self, command: RemoveReservation): reservation_id = command.Id reservation = self.factory.get(self.aggregate_type, reservation_id) # todo complete exercise 7 and implement this command in the next exercise # events = reservation.RemoveReservation(command) self.event_store_client.Save(reservation)
def __init__(self): self.factory = AggregateFactory() self.event_store_client = EventStoreClient() self.aggregate_type = type(Reservation())