Пример #1
0
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
Пример #2
0
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)
Пример #3
0
 def __init__(self):
     self.factory = AggregateFactory()
     self.event_store_client = EventStoreClient()
     self.aggregate_type = type(Reservation())