private void Update(Concert aggregateRoot) { var snapshot = ConcertSnapshot.CreateFrom(aggregateRoot); var concertEntity = _db.Concerts.Find(aggregateRoot.Id.AsGuid()); concertEntity.ModifyWithConcertSnapshot(snapshot); _db.SaveChanges(); }
public void Store(Concert aggregateRoot) { if ((aggregateRoot as IHasDomainEvents).NewlyCreated()) { var snapshot = ConcertSnapshot.CreateFrom(aggregateRoot); _db.Concerts.Add(ConcertEntity.FromConcertSnapshot(snapshot)); _db.SaveChanges(); } else { Update(aggregateRoot); } }
public void Delete(Concert aggregateRoot) { _db.Concerts.Remove(ConcertEntity.FromConcertSnapshot(ConcertSnapshot.CreateFrom(aggregateRoot))); _db.SaveChanges(); }