Last active
August 29, 2015 14:07
-
-
Save mox601/cfdaca9d3f151e516639 to your computer and use it in GitHub Desktop.
ddd to view
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
//an event | |
// new ItemAdded("item-id-34", 45$, "2014-10-21-18:47:12") | |
//the handler | |
public class MonthlyCostsDenormalizer implements IHandle<ItemAddedToCart> { | |
private MonthlyCostsDao dao | |
public MonthlyCostsDenormalizer(MonthlyCostsDao dao) { | |
this.dao = dao; | |
} | |
public void handle(ItemAddedToCart) { | |
MonthlyCosts view = dao.getById(parseYearAndMonth(item.getHappenedAt())); | |
view.add(item.getCost()); | |
repository.update(view); | |
} | |
private static String parseYearAndMonth(DateTime date) { | |
// for the example returns "2014-10" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment