Example #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="cancellationToken">Propagates notification that operations should be canceled.</param>
        /// <returns></returns>
        public new async Task <int> SaveChangesAsync(CancellationToken cancellationToken)
        {
            try
            {
                Validate();
                _auditableService?.Audit(this);
                return(await base.SaveChangesAsync(cancellationToken));
            }
            catch (Exception ex)
            {
                await RollbackAsync(cancellationToken);

                throw new SharedKernelInfrastructureException(nameof(ExceptionCodes.EF_CORE_SAVE_CHANGES), ex);
            }
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="cancellationToken">Propagates notification that operations should be canceled.</param>
        /// <returns></returns>
        public new async Task <int> SaveChangesAsync(CancellationToken cancellationToken)
        {
            try
            {
                Validate();
                _auditableService?.Audit(this);
                var result = await base.SaveChangesAsync(cancellationToken);

                if (_eventBus != default)
                {
                    await DispatchDomainEventsAsync(cancellationToken);
                }

                return(result);
            }
            catch (Exception ex)
            {
                await RollbackAsync(cancellationToken);

                throw new SharedKernelInfrastructureException(nameof(ExceptionCodes.EF_CORE_SAVE_CHANGES), ex);
            }
        }