/// <summary> /// Checks whether, after this plan, the owner will be eligible to the provided certificate /// </summary> /// <param name="certLevel">The cert level.</param> /// <returns></returns> /// <exception cref="System.ArgumentNullException">certLevel</exception> public bool WillGrantEligibilityFor(CertificateLevel certLevel) { certLevel.ThrowIfNull(nameof(certLevel)); if (certLevel.IsTrained) { return(true); } // We check every prerequisite is trained return(!certLevel.PrerequisiteSkills.Select( skillToTrain => new { skillToTrain, skill = skillToTrain.Skill }).Where( skillToTrain => skillToTrain.skill.Level < skillToTrain.skillToTrain.Level).Where( skillToTrain => !IsPlanned(skillToTrain.skill, skillToTrain.skillToTrain.Level)).Select( skill => skill.skillToTrain).Any()); }
/// <summary> /// Adds the provided certificate's prerequisites to the plan. /// </summary> /// <param name="certificateLevel">The certificate level.</param> /// <returns></returns> /// <exception cref="System.ArgumentNullException">certificateLevel</exception> public IPlanOperation TryPlanTo(CertificateLevel certificateLevel) { certificateLevel.ThrowIfNull(nameof(certificateLevel)); List <StaticSkillLevel> skillsToAdd = new List <StaticSkillLevel>(); foreach (SkillLevel skillLevel in certificateLevel.PrerequisiteSkills) { int plannedLevel = GetPlannedLevel(skillLevel.Skill); if ((skillLevel.Level == plannedLevel) || (skillLevel.Level <= plannedLevel)) { continue; } // Get skill levels to add for (int i = plannedLevel + 1; i <= skillLevel.Level; i++) { skillsToAdd.Add(new StaticSkillLevel(skillLevel.Skill, i)); } } return(TryAddSet(skillsToAdd, $"{certificateLevel.Certificate.Name} {certificateLevel}")); }