Example #1
0
        public override string Handle(string input)
        {
            var addConferenceCommand = JsonConvert.DeserializeObject <NewRegistration>(input);
            var conferenceHandler    = new ConferenceHandler();
            var events = conferenceHandler.Handle(addConferenceCommand).ToArray();

            var dl = new CommandDataLayer();

            dl.SaveEventData(events);

            var commandResult = new CommandResult
            {
                CommandName = "NewRegistration",
                EventId     = events.Select(x => x.Id).ToArray()
            };

            using (var bus = new EventBus())
            {
                foreach (var e in events)
                {
                    bus.Publish(e);
                }
            }

            return(JsonConvert.SerializeObject(commandResult));
        }
Example #2
0
        public override void Handle(string input)
        {
            var addConferenceCommand = JsonConvert.DeserializeObject <AddConference>(input);
            var conferenceHandler    = new ConferenceHandler();
            var events = conferenceHandler.Handle(addConferenceCommand).ToArray();

            var dl = new CommandDataLayer();

            dl.SaveEventData(events);

            var commandResult = new CommandResult
            {
                CommandName = "AddConference",
                EventId     = events.Select(x => x.Id).ToArray()
            };

            Context.WriteContent(JsonConvert.SerializeObject(commandResult));
            using (var bus = new EventBus())
            {
                foreach (var e in events)
                {
                    bus.Publish(e);
                }
            }
        }