private void UpdateUserSkills(BllProgrammer balProgrammer) { var dbUserSkills = userSkillRepo.Get(x => x.User.Id == balProgrammer.Id); foreach (var skill in balProgrammer.Skills) { DalUserSkill dalUserSkill = new DalUserSkill { User = (DalProgrammer)balProgrammer.ToDal(), Skill = skill.Key.ToDal(), Level = skill.Value }; if (dbUserSkills.Any(x => x.Skill.Id == skill.Key.Id)) { userSkillRepo.Update(dalUserSkill); } else { userSkillRepo.Create(dalUserSkill); } } foreach (var skill in dbUserSkills) { if (!balProgrammer.Skills.Any(x => x.Key.Id == skill.Skill.Id)) { userSkillRepo.Remove(skill); } } }
public static BllUserSkill ToBal(this DalUserSkill skill) { return(new BllUserSkill { Skill = skill.Skill.ToBal(), User = (BllProgrammer)skill.User.ToBal(), Level = skill.Level }); }