Beispiel #1
0
        public async Task Update(ApprenticeshipIncentiveModel apprenticeshipIncentive)
        {
            var updatedIncentive = apprenticeshipIncentive.Map();

            var existingIncentive = await _dbContext.ApprenticeshipIncentives.FirstOrDefaultAsync(x => x.Id == updatedIncentive.Id);

            if (existingIncentive != null)
            {
                UpdateApprenticeshipIncentive(updatedIncentive, existingIncentive);
            }
        }
Beispiel #2
0
        public async Task Delete(ApprenticeshipIncentiveModel apprenticeshipIncentive)
        {
            var deletedIncentive = apprenticeshipIncentive.Map();

            var existingIncentive = await _dbContext.ApprenticeshipIncentives.FirstOrDefaultAsync(x => x.Id == deletedIncentive.Id);

            foreach (var pendingPayment in existingIncentive.PendingPayments)
            {
                foreach (var validationResult in pendingPayment.ValidationResults)
                {
                    _dbContext.Remove(validationResult);
                }
                _dbContext.Remove(pendingPayment);
            }
        }
Beispiel #3
0
 public async Task Add(ApprenticeshipIncentiveModel apprenticeshipIncentive)
 {
     await _dbContext.AddAsync(apprenticeshipIncentive.Map());
 }
Beispiel #4
0
 public async Task Add(ApprenticeshipIncentiveModel apprenticeshipIncentive)
 {
     var incentive = apprenticeshipIncentive.Map();
     await _dbContext.AddAsync(incentive);
 }