예제 #1
0
        public async Task AddAsync(ITransfer model)
        {
            using (var context = _contextFactory.CreateDataContext())
            {
                var entity = TransferEventDataEntity.Create(model);

                await context.TransferEventsData.AddAsync(entity);

                try
                {
                    await context.SaveChangesAsync();
                }
                catch (DbUpdateException e)
                {
                    if (e.InnerException is SqlException sqlException &&
                        sqlException.Number == MsSqlErrorCodes.PrimaryKeyConstraintViolation)
                    {
                        _log.Warning("Error on transfer event context saving", e);
                    }
예제 #2
0
        public async Task AddAsync(ITransfer model)
        {
            using (var context = _contextFactory.CreateDataContext())
            {
                var entity = TransferEventDataEntity.Create(model);

                await context.TransferEventsData.AddAsync(entity);

                try
                {
                    await context.SaveChangesAsync();
                }
                catch (DbUpdateException e)
                {
                    if (e.InnerException is PostgresException sqlException &&
                        sqlException.SqlState == PostgresErrorCodes.UniqueViolation)
                    {
                        _log.Warning("Error on transfer event context saving", e);
                    }