public async Task Store(CommitmentModel commitment)
        {
            try
            {
                _logger.Info($"Store Commitment Id {commitment.Id}");
                var startTime = DateTime.UtcNow;
                var stopwatch = new Stopwatch();
                stopwatch.Start();
                if (commitment.Id <= 0)
                {
                    _dataContext.Commitments.Add(commitment);
                }

                await _dataContext.SaveChangesAsync();

                stopwatch.Stop();

                _telemetry.TrackDependency(DependencyType.SqlDatabaseQuery, "Store Commitment", startTime, stopwatch.Elapsed, true);
            }
            catch (DbEntityValidationException ex)
            {
                var errorMessages    = ex.EntityValidationErrors.SelectMany(x => x.ValidationErrors).Select(x => x.ErrorMessage);
                var fullErrorMessage = string.Join("; ", errorMessages);
                var exceptionMessage = string.Concat(ex.Message, " The validation errors are: ", fullErrorMessage);
                _logger.Error(ex, exceptionMessage);
            }
            catch (Exception ex)
            {
                _logger.Error(ex, $"Store Commitment Failed for CommitmentId {commitment.Id}");
            }
        }
        public async Task Store(Models.Balance.BalanceModel balance)
        {
            var persistedBalance = await Get(balance.EmployerAccountId);

            if (persistedBalance != null)
            {
                persistedBalance.Amount                        = balance.Amount;
                persistedBalance.BalancePeriod                 = balance.BalancePeriod;
                persistedBalance.ReceivedDate                  = balance.ReceivedDate;
                persistedBalance.RemainingTransferBalance      = balance.RemainingTransferBalance;
                persistedBalance.TransferAllowance             = balance.TransferAllowance;
                persistedBalance.UnallocatedCompletionPayments = balance.UnallocatedCompletionPayments;
            }
            else
            {
                if (balance.ReceivedDate != DateTime.MinValue && balance.BalancePeriod != DateTime.MinValue)
                {
                    _forecastingDataContext.Balances.Add(balance);
                }
            }
            var stopwatch = new Stopwatch();

            stopwatch.Start();
            var startTime = DateTime.UtcNow;
            await _forecastingDataContext.SaveChangesAsync();

            stopwatch.Stop();
            _telemetry.TrackDependency(DependencyType.SqlDatabaseUpdate, "Store Balance", startTime, stopwatch.Elapsed, true);
        }
Ejemplo n.º 3
0
        public async Task SaveChanges()
        {
            var stopwatch = new Stopwatch();

            stopwatch.Start();
            var startTime = DateTime.UtcNow;
            await _dataContext.SaveChangesAsync();

            _telemetry.TrackDependency("EF Context Save Changes", "Account Projections", startTime, stopwatch.Elapsed, true);
        }
        public async Task SaveChanges()
        {
            var stopwatch = new Stopwatch();
            var startTime = DateTime.UtcNow;

            stopwatch.Start();
            await _dataContext.SaveChangesAsync();

            stopwatch.Stop();
            _telemetry.TrackDependency(DependencyType.SqlDatabaseInsert, "Store Payment", startTime, stopwatch.Elapsed, true);
        }
 public async Task SaveChanges()
 {
     await _dataContext.SaveChangesAsync();
 }