Created
August 1, 2016 07:19
-
-
Save pawelkaczor/4e958a218a0097a5b52c5040d55b3d75 to your computer and use it in GitHub Desktop.
Reservation Projection
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ReservationProjection(dao: ReservationDao)(implicit ec: ExecutionContext) extends Projection { | |
override def consume(eventMsg: OfficeEventMessage): ProjectionAction[Write] = { | |
eventMsg.event match { | |
case ReservationCreated(id, clientId) => | |
val newView = ReservationView(id, clientId, Opened, new Date(now().getMillis)) | |
dao.createOrUpdate(newView) | |
case ReservationConfirmed(id, clientId, _) => | |
dao.updateStatus(id, Confirmed) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment