Exemple #1
0
        public async Task AddAsync(IBonusIssued model)
        {
            using (var context = _contextFactory.CreateDataContext())
            {
                var entity = BonusIssuedEventDataEntity.Create(model);

                await context.BonusIssuedEventsData.AddAsync(entity);

                try
                {
                    await context.SaveChangesAsync();
                }
                catch (DbUpdateException e)
                {
                    if (e.InnerException is SqlException sqlException &&
                        sqlException.Number == MsSqlErrorCodes.PrimaryKeyConstraintViolation)
                    {
                        _log.Warning("Error on bonus issued event context saving", e);
                    }
        public async Task AddAsync(IBonusIssued model)
        {
            using (var context = _contextFactory.CreateDataContext())
            {
                var entity = BonusIssuedEventDataEntity.Create(model);

                await context.BonusIssuedEventsData.AddAsync(entity);

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