Exemple #1
0
        public async Task SaveChangesAsync()
        {
            if (unsavedChangeRecords.Count == 0)
            {
                return;
            }

            var recs = unsavedChangeRecords.ToList();

            unsavedChangeRecords.Clear();

            crudRepository.AddRange(recs);
            await crudRepository.SaveChangesAsync();

            foreach (TrackedChangeRecord changeRecord in recs)
            {
                await eventBus.PublishAsync(new EventMessage <TrackedChangeAdded>(
                                                new TrackedChangeAdded()
                {
                    TrackedChangeId = changeRecord.Id,
                    AggregateClassId = changeRecord.AggregateClassId,
                    AggregateId = changeRecord.AggregateId,
                    EntityClassId = changeRecord.EntityClassId,
                    EntityId = changeRecord.EntityId
                },
                                                new Dictionary <string, string>()));
            }
        }
Exemple #2
0
        public async Task <IEnumerable <TKey> > Add(IEnumerable <T> values)
        {
            using (var trans = _unitOfWork.BeginTransaction())
            {
                await ValidateDto(values, ValidationType.AddValidation);

                var entities = MapFromDtos(values, ValidationType.AddValidation);

                foreach (var entity in entities)
                {
                    AddEntity(entity);
                }

                _repository.AddRange(entities);

                await CommitTransaction(trans);

                return(entities.Select(GetKey));
            }
        }