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); } }
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); } }
public async Task Add(ApprenticeshipIncentiveModel apprenticeshipIncentive) { await _dbContext.AddAsync(apprenticeshipIncentive.Map()); }
public async Task Add(ApprenticeshipIncentiveModel apprenticeshipIncentive) { var incentive = apprenticeshipIncentive.Map(); await _dbContext.AddAsync(incentive); }