public void Like(string userId, string sessionId) { var evt = new ArticleLikedEvent(Guid.NewGuid().ToString(), Id, Version + 1, Language, userId, sessionId, DateTime.UtcNow); Handle(evt); DomainEvts.Add(evt); }
private void Handle(ArticleLikedEvent evt) { if (ArticleLikeLst.Any(l => l.UserId == evt.UserId)) { throw new DomainException(Global.ArticleAlreadyLikedByTheUser); } NbLikes++; Version = evt.Version; UpdateDateTime = evt.ActionDateTime; ArticleLikeLst.Add(ArticleLike.Create(evt.UserId, evt.ActionDateTime)); }