protected override PersonEventStore GetEventStoreEntity(Person aggregateEntity, bool addIfNotFound) { var store = EventStores.FirstOrDefault(s => s.Id == aggregateEntity.Id); if (store == null && addIfNotFound) { store = new PersonEventStore { Id = aggregateEntity.Id, Ssn = aggregateEntity.Ssn }; EventStores.Add(store); } return(store); }
public Person GetSnapshotById(int id, DateTime snapshot) => GetAggregateEntity(EventStores.FirstOrDefault(x => x.Id == id), snapshot);
public Person GetById(int id) => GetAggregateEntity(EventStores.FirstOrDefault(x => x.Id == id));
public Person GetBySsn(string ssn) => GetAggregateEntity(EventStores.FirstOrDefault(x => x.Ssn == ssn));
protected override PersonEventStore?GetEventStoreEntity(Person domainEntity) => EventStores.FirstOrDefault(s => s.Id == domainEntity.Id);
public PersonInMemoryEventStoreRepository(IEnumerable <PersonEventStore> eventStoreEntities) { EventStores.AddRange(eventStoreEntities); }
protected override void AddEventStoreEntity(PersonEventStore eventStoreEntity) => EventStores.Add(eventStoreEntity);
public Person GetById(int id) => GetDomainEntity(EventStores.FirstOrDefault(x => x.Id == id));
public PersonInMemoryEventStoreRepository(IEnumerable <PersonEventStore> eventStoreEntities) { eventStoreEntities.ForEach(personEventStore => EventStores.Add(personEventStore)); }
public Person GetSnapshotById(int id, DateTime snapshot) => GetDomainEntity(EventStores.First(x => x.Id == id), snapshot);
public Person GetBySsn(string ssn) => GetDomainEntity(EventStores.First(x => x.Ssn == ssn));