public FeedDataSourceSubscribedEvent SubscribeDataSource(string userId, string datasourceId) { var evt = new FeedDataSourceSubscribedEvent(Guid.NewGuid().ToString(), Id, Version + 1, Title, userId, datasourceId, DateTime.UtcNow); Handle(evt); DomainEvts.Add(evt); return(evt); }
private void Handle(FeedDataSourceSubscribedEvent evt) { if (UserId != evt.UserId) { throw new DomainException(Global.UserNotAuthorizedToSubscribe); } if (DataSources.Any(d => d.DatasourceId == evt.DataSourceId)) { throw new DomainException(string.Format(Global.DatasourceAlreadyExists, evt.DataSourceId)); } DataSources.Add(FeedDatasource.Create(evt.DataSourceId)); UpdateDateTime = evt.CreateDateTime; Version = evt.Version; }