public async Task Add(LearnerModel learnerModel) { var learner = learnerModel.Map(); learner.CreatedDate = DateTime.Now; learner.LearningPeriods.ToList().ForEach(l => l.CreatedDate = learner.CreatedDate); learner.DaysInLearnings.ToList().ForEach(l => l.CreatedDate = learner.CreatedDate); await _dbContext.AddAsync(learner); }
public async Task Update(LearnerModel learnerModel) { var updatedLearner = learnerModel.Map(); var existingLearner = await _dbContext.Learners.FirstOrDefaultAsync(x => x.Id == updatedLearner.Id); if (existingLearner != null) { UpdateLearner(updatedLearner, existingLearner); } }