Ejemplo n.º 1
0
        public void Handle(ConferenceUpdated @event)
        {
            using (var context = this._contextFactory.Invoke()) {
                var confDto = context.Find <ReadModel.Conference>(@event.SourceId);

                if (confDto != null)
                {
                    confDto.Code          = @event.Slug;
                    confDto.Description   = @event.Description;
                    confDto.Location      = @event.Location;
                    confDto.Name          = @event.Name;
                    confDto.StartDate     = @event.StartDate;
                    confDto.Tagline       = @event.Tagline;
                    confDto.TwitterSearch = @event.TwitterSearch;

                    context.SaveChanges();
                }
                else
                {
                    throw new InvalidOperationException(
                              string.Format("Failed to locate Conference read model for updated conference with id {0}.",
                                            @event.SourceId));
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Invoked when a message stanza has been received.
        /// </summary>
        /// <param name="stanza">The stanza which has been received.</param>
        /// <returns>true to intercept the stanza or false to pass the stanza
        /// on to the next handler.</returns>
        public bool Input(Message message)
        {
            if (message.Type == MessageType.Chat)
            {
                // Do we receive a conference-info message ?
                if (message.Data["conference-info"] != null)
                {
                    ConferenceUpdated.Raise(this, new Sharp.Xmpp.Extensions.MessageEventArgs(message.Data["conference-info"].ToXmlString()));
                    return(true);
                }
            }

            // Pass the message on to the next handler.
            return(false);
        }
        public void Handle(ConferenceUpdated @event)
        {
            var dto = GetConferenceView(@event.SourceId);

            if (dto != null)
            {
                dto.Code          = @event.Slug;
                dto.Description   = @event.Description;
                dto.Location      = @event.Location;
                dto.Name          = @event.Name;
                dto.StartDate     = @event.StartDate;
                dto.Tagline       = @event.Tagline;
                dto.TwitterSearch = @event.TwitterSearch;

                conferenceRepository.Update(dto);
            }
            else
            {
                throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture,
                                                                  "Failed to locate Conference read model for updated conference with id {0}.",
                                                                  @event.SourceId));
            }
        }
Ejemplo n.º 4
0
 public Task HandleAsync(ConferenceUpdated evnt)
 {
     return(TryUpdateRecordAsync(connection =>
     {
         var info = evnt.Info;
         return connection.UpdateAsync(new
         {
             Name = info.Name,
             Description = info.Description,
             Location = info.Location,
             Tagline = info.Tagline,
             TwitterSearch = info.TwitterSearch,
             StartDate = info.StartDate,
             EndDate = info.EndDate,
             IsPublished = 0,
             Version = evnt.Version,
             EventSequence = evnt.Sequence
         }, new
         {
             Id = evnt.AggregateRootId,
             Version = evnt.Version - 1
         }, ConfigSettings.ConferenceTable);
     }));
 }