public static FeedAggregate Create(string userId, string title) { var result = new FeedAggregate(); var evt = new FeedAddedEvent(Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), 0, userId, title, DateTime.UtcNow); result.Handle(evt); return(result); }
private void Handle(FeedAddedEvent evt) { if (string.IsNullOrWhiteSpace(evt.Title)) { throw new DomainException(Global.TitleIsEmpty); } if (string.IsNullOrWhiteSpace(evt.UserId)) { throw new DomainException(Global.UserIdIsEmpty); } Id = evt.AggregateId; UserId = evt.UserId; Title = evt.Title; CreateDateTime = evt.CreateDateTime; }