public static Tuple<List<Dinner>, List<Event>> CreateTestDinners()
        {
            List<Dinner> dinners = new List<Dinner>();
            List<Event> events = new List<Event>();

            for (int i = 1; i <= 101; i++)
            {

                Dinner sampleDinner = new Dinner()
                {
                    DinnerID = i,
                    DinnerGuid = Guid.NewGuid(),
                    Title = "Sample Dinner",
                    HostedBy = "SomeUser",
                    Address = "Some Address",
                    Country = "USA",
                    ContactPhone = "425-555-1212",
                    Description = "Some description",
                    EventDate = DateTime.Now.AddDays(i),
                    Latitude = 99,
                    Longitude = -99
                };
                dinners.Add(sampleDinner);

                var e = new Event();
                e.Data = @"{""Name"":""SomeUser"",""FriendlyName"":""SomeUser""}";
                e.EventType = "NerdDinner.Events.RSVPed";
                e.DateTime = DateTime.UtcNow;
                e.AggregateId = sampleDinner.DinnerGuid;
                events.Add(e);
            }

            return Tuple.Create(dinners, events);
        }
        public void StoreEventsForDinner(Dinner dinner)
        {
            foreach (var publishedEvent in dinner.PublishedEvents) {
                var e = new Event();
                e.AggregateId = dinner.DinnerGuid;
                e.Data        = JsonConvert.SerializeObject(publishedEvent);
                e.DateTime    = DateTime.UtcNow;

                db.Events.Add(e);
            }
        }
Ejemplo n.º 3
0
 void ApplyEvent(Event<RSVPed> @event)
 {
     var rsvp = new RSVP();
     rsvp.DinnerID       = this.DinnerID;
     rsvp.AttendeeName   = @event.Data.FriendlyName;
     rsvp.AttendeeNameId = @event.Data.Name;
     _rsvps.Add(rsvp);
 }
Ejemplo n.º 4
0
 private void RaiseEvent(Event e)
 {
     EventScope.Raise(e);
     _currentEvent++;
 }
Ejemplo n.º 5
0
 void Apply(Event e)
 {
     ApplyEvent(e.AddEventType());
 }
Ejemplo n.º 6
0
 private void RaiseEvent(Event e)
 {
     _publishedEvents.Add(e);
     _currentEvent++;
 }
Ejemplo n.º 7
0
        void ApplyEvent(Event<AddressChanged> @event)
        {
            this.Address = @event.Data.NewAddress;

            if(@event.Data.Reason!=null) {
                _eventHistory.Add(String.Format("{0} Address changed to: {1}, because of: {2}", @event.DateTime.ToString("g"), @event.Data.NewAddress, @event.Data.Reason));
                return;
            }

            _eventHistory.Add(String.Format("{0} Address changed to: {1}", @event.DateTime.ToString("g"), @event.Data.NewAddress));
        }
Ejemplo n.º 8
0
        void ApplyEvent(Event<RSVPCanceled> @event)
        {
            var rsvp = _rsvps.Single(r => r.AttendeeName == @event.Data.Name);
            _rsvps.Remove(rsvp);

            _eventHistory.Add(String.Format("{0} {1} canceled", @event.DateTime.ToString("g"), @event.Data.Name));
        }
Ejemplo n.º 9
0
        void ApplyEvent(Event<RSVPed> @event)
        {
            var rsvp = new RSVP();
            rsvp.DinnerID = this.DinnerID;
            rsvp.AttendeeName = @event.Data.FriendlyName;
            rsvp.AttendeeNameId = @event.Data.Name;
            _rsvps.Add(rsvp);

            _eventHistory.Add(String.Format("{0} {1} RSVPed", @event.DateTime.ToString(""), @event.Data.Name));
        }