// [AbpAuthorize(PermissionNames.Pages_Group6_Recruitment_Create)] public async Task <RecruitmentDto> UpdateRecruitmentAsync(UpdateRecruitmentDto input) { var recruitment = await _recruitmentRepo.GetAsync(input.Id); ObjectMapper.Map(input, recruitment); List <ExpertiseRecruitment> List_expertiseRecruitments = _expertiseRecruitmentRepo.GetAll() .Where(er => er.RecruitmentId == input.Id).ToList(); foreach (ExpertiseRecruitment temp in List_expertiseRecruitments) { System.Diagnostics.Debug.WriteLine("[INFO]\t" + temp.Id + "\n"); await _expertiseRecruitmentRepo.DeleteAsync(temp); } foreach (ExpertiseDto ept in input.Expertises) { Expertise expertise = await _expertiseRepo.FirstOrDefaultAsync(e => e.Id == ept.Id); if (expertise != null) { ExpertiseRecruitment er = new ExpertiseRecruitment { Expertise = expertise, ExpertiseId = expertise.Id, Recruitment = recruitment, RecruitmentId = recruitment.Id }; await _expertiseRecruitmentRepo.InsertAsync(er); } } var savedRecruitment = await _recruitmentRepo.UpdateAsync(recruitment); await CurrentUnitOfWork.SaveChangesAsync(); return(ObjectMapper.Map <RecruitmentDto>(savedRecruitment)); }
// [AbpAuthorize(PermissionNames.Pages_Group6_Recruitment_Create)] public async Task <RecruitmentDto> CreateRecruitmentAsync(CreateRecruitmentDto input) { var recruitment = ObjectMapper.Map <Recruitment>(input); foreach (ExpertiseForCRcrmDto ept in input.Expertises) { Expertise expertise = await _expertiseRepo.FirstOrDefaultAsync(e => e.Id == ept.Id); //System.Diagnostics.Debug.WriteLine("[InForeach]\t" +ept.Id + "\n"); if (expertise != null) { // System.Diagnostics.Debug.WriteLine("[NotNull]\t" + ept.Id + "\n"); ExpertiseRecruitment er = new ExpertiseRecruitment { Expertise = expertise, ExpertiseId = expertise.Id, Recruitment = recruitment, RecruitmentId = recruitment.Id }; await _expertiseRecruitmentRepo.InsertAsync(er); } } recruitment = await _recruitmentRepo.InsertAsync(recruitment); await CurrentUnitOfWork.SaveChangesAsync(); return(ObjectMapper.Map <RecruitmentDto>(recruitment)); }