public void AddSkill(Skill skill, short level) { var requiredSkill = new ProjectRequiredSkill { Project = this, ProjectId = Id, Skill = skill, SkillId = skill.Id, Level = level }; var index = SkillsToDelete.IndexOf(s => s == requiredSkill); if (index == -1) { SkillsToAdd.Add(requiredSkill); } else { SkillsToDelete.RemoveAt(index); } }
public void AddSkill(Skill skill, short level) { var employeeSkill = new EmployeeSkill { Employee = this, EmployeeId = Id, Skill = skill, SkillId = skill.Id, Level = level }; var index = SkillsToDelete.IndexOf(s => s == employeeSkill); if (index == -1) { SkillsToAdd.Add(employeeSkill); } else { SkillsToDelete.RemoveAt(index); } }
public void UpdateSkills() { var skills = new List <ProjectRequiredSkill>(); if (!Requiredskillsidfks.IsEmpty() && !SkillsToAdd.IsEmpty()) { skills = Requiredskillsidfks.Union(SkillsToAdd).ToList(); } else if (!Requiredskillsidfks.IsEmpty()) { skills = Requiredskillsidfks.ToList(); } else if (!SkillsToAdd.IsEmpty()) { skills = SkillsToAdd; } Skills = new ObservableCollection <ProjectRequiredSkill>( skills.Where(rs => !SkillsToDelete.Any(s => s == rs)) ); RaisePropertyChanged(nameof(Skills)); }
public void SaveSkills(long id = 0) { SkillsToAdd.ForEach(s => { if (SkillsToDelete.Any(sd => sd == s)) { return; } if (id != 0) { s.ProjectId = id; } DBModel.Context.Insert(s); }); SkillsToDelete.ForEach(s => { if (s.ProjectId != 0) { DBModel.EmployeesDB.Delete(s); } }); }
public void UpdateSkills() { var skills = new List <EmployeeSkill>(); if (!Skillidfks.IsEmpty() && !SkillsToAdd.IsEmpty()) { skills = Skillidfks.Union(SkillsToAdd).ToList(); } else if (!Skillidfks.IsEmpty()) { skills = Skillidfks.ToList(); } else if (!SkillsToAdd.IsEmpty()) { skills = SkillsToAdd; } Skills = new ObservableCollection <EmployeeSkill>( skills.Where(es => !SkillsToDelete.Any(s => s == es)) ); RaisePropertyChanged(nameof(Skills)); }