Пример #1
0
        public static void ActivateCommand(Commands cmd, Aggregate agregate)
        {
            string[]           agregateType = agregate.GetType().ToString().Split('.');
            string             agregateId   = agregateType[2] + "." + cmd.Id;
            List <EventFromES> eventStream  = new List <EventFromES>();

            try
            {
                eventStream = EventStoreInterface.HydrateFromES(agregateId);
            }
            catch (Exception e) { Console.Write(e); }
            if (eventStream.Count > 0)
            {
                foreach (var evt in eventStream)
                {
                    try
                    {
                        agregate.Hydrate(evt);
                    }
                    catch (Exception e)
                    {
                        Console.Write(e);
                    }
                }
            }
            Events[] toComplete = agregate.Execute(cmd);
            foreach (var evt in toComplete)
            {
                evt.StreamId  = agregateId;
                evt.TimeStamp = DateTime.Now;
                EventStoreInterface.PublishToEventStore(evt);
            }
        }
Пример #2
0
        public static void ActivateCommand(Commands cmd, Aggregate aggregate)
        {
            List <EventFromES> eventStream = new List <EventFromES>();

            try
            {
                eventStream = EventStoreInterface.HydrateFromES(cmd.Id);
            }catch (Exception e) { Console.Write(e); }
            if (eventStream.Count > 0)
            {
                foreach (var evt in eventStream)
                {
                    aggregate.Hydrate(evt);
                }
            }
            aggregate.Execute(cmd);
        }