示例#1
0
        private void TryRaiseTweetCreatedEvents(string eventName, JObject jsonObjectEvent)
        {
            var json = jsonObjectEvent.ToString();
            var tweetCreatedEvent     = jsonObjectEvent[eventName];
            var tweetCreatedEventJson = tweetCreatedEvent.ToString();
            var tweetDTOs             = _jsonObjectConverter.Deserialize <ITweetDTO[]>(tweetCreatedEventJson);

            tweetDTOs.ForEach(tweetDTO =>
            {
                var tweet = _factories.CreateTweet(tweetDTO);

                var accountActivityEvent = new AccountActivityEvent <ITweet>(tweet)
                {
                    AccountUserId = AccountUserId,
                    EventDate     = tweet.CreatedAt,
                    Json          = json
                };

                var eventArgs = new TweetCreatedEvent(accountActivityEvent);
                this.Raise(TweetCreated, eventArgs);

                if (eventArgs.InResultOf == TweetCreatedRaisedInResultOf.Unknown)
                {
                    this.Raise(EventKnownButNotFullySupportedReceived, new EventKnownButNotSupported(json, eventArgs));
                }
            });
        }
示例#2
0
        public void Handle(RequestTweetCommand message)
        {
            var request  = TweetRequest.Factory.Create(message.TweetId, message.Text, message.MediaUrl);
            var response = _repository.CreateTweetFromRequest(request);

            if (!response.Success)
            {
                var rejected = new TweetRequestRejectedEvent(request.Id, response.Description);
                Bus.RaiseEvent(rejected);
                return;
            }

            //var slotInfo = request.ToSlotInfo();
            var created = new TweetCreatedEvent(); //request.Id, response.AggregateId, slotInfo);

            Bus.RaiseEvent(created);
        }
 // Tweet events
 private void TweetCreated(object sender, TweetCreatedEvent e)
 {
     Console.WriteLine($">>> Tweet has been created:\n{e.Tweet}");
 }