private static void RefreshExistingVacanciesProgress(Vacancy destination, VacancyDTO source, IVacancyStageInfoRepository vacancyStageInfoRepository) { source.CandidatesProgress.Where(x => !x.IsNew()).ToList().ForEach(updatedVacanciesStageInfo => { var domainVacancyStageInfo = destination.CandidatesProgress.FirstOrDefault(x => x.Id == updatedVacanciesStageInfo.Id); if (domainVacancyStageInfo == null) { throw new ArgumentNullException("You trying to update vacanies progress which is actually doesn't exists in database"); } if (updatedVacanciesStageInfo.ShouldBeRemoved()) { vacancyStageInfoRepository.Delete(updatedVacanciesStageInfo.Id); } else { domainVacancyStageInfo.Update(destination, updatedVacanciesStageInfo); } }); }
private static void PerformVacanciesProgressSaving(Vacancy destination, VacancyDTO source, IVacancyStageInfoRepository vacancyStageInfoRepository) { //TODO: if vacancy id null - set to THIS RefreshExistingVacanciesProgress(destination, source, vacancyStageInfoRepository); CreateNewVacanciesProgress(destination, source); }