public Person Get(int id)
        {
            var           events   = _eventDataRepository.GetEventDatas(nameof(Person), id);
            Person        person   = new Person();
            List <IEvent> myevents = new List <IEvent>();

            foreach (var item in events)
            {
                switch (item.EventType)
                {
                case nameof(PersonCreated):
                    PersonCreated personCreated = JsonConvert.DeserializeObject <PersonCreated>(item.EventSerializedData);
                    myevents.Add(personCreated);
                    break;

                case nameof(PersonEmailUpdated):
                    PersonEmailUpdated personEmailUpdate = JsonConvert.DeserializeObject <PersonEmailUpdated>(item.EventSerializedData);
                    myevents.Add(personEmailUpdate);

                    break;
                }
            }
            person.LoadFromEvents(myevents);
            return(person);
        }
Ejemplo n.º 2
0
 public void LoadCreattion(PersonCreated personCreated)
 {
     Id        = personCreated.Id;
     FirstName = personCreated.FirstName;
     Email     = personCreated.Email;
     LastName  = personCreated.LastName;
 }