Пример #1
0
        public void PopulateAssignedCourseData(RandyPowellContext context,
                                               Experience experience)
        {
            var allSkills        = context.Skill;
            var experienceSkills = new HashSet <int>(
                experience.ExperienceSkills.Select(c => c.SkillId));

            ExperienceSkillList = new List <ExperienceSkill>();
            foreach (var skill in allSkills)
            {
                ExperienceSkillList.Add(new ExperienceSkill
                {
                    SkillId      = skill.ID,
                    Skill        = skill,
                    Experience   = experience,
                    ExperienceId = experience.ID
                });
            }
        }
Пример #2
0
        public void UpdateInstructorCourses(RandyPowellContext context,
                                            string[] selectedSkills, Experience experienceToUpdate)
        {
            if (selectedSkills == null)
            {
                experienceToUpdate.ExperienceSkills = new List <ExperienceSkill>();
                return;
            }

            var selectedSkillsHS = new HashSet <string>(selectedSkills);
            var experienceSkills = new HashSet <int>
                                       (experienceToUpdate.ExperienceSkills.Select(c => c.SkillId));

            foreach (var skill in context.Skill)
            {
                if (selectedSkillsHS.Contains(skill.ID.ToString()))
                {
                    if (!experienceSkills.Contains(skill.ID))
                    {
                        experienceToUpdate.ExperienceSkills.Add(
                            new ExperienceSkill
                        {
                            ExperienceId = experienceToUpdate.ID,
                            SkillId      = skill.ID,
                            Skill        = skill,
                            Experience   = experienceToUpdate
                        });
                    }
                }
                else
                {
                    if (experienceSkills.Contains(skill.ID))
                    {
                        ExperienceSkill skillToRemove
                            = experienceToUpdate
                              .ExperienceSkills
                              .SingleOrDefault(i => i.SkillId == skill.ID);
                        context.Remove(skillToRemove);
                    }
                }
            }
        }
Пример #3
0
 public ExperienceController(RandyPowellContext context)
 {
     _context = context;
 }
Пример #4
0
 public SkillController(RandyPowellContext context)
 {
     _context = context;
 }