public void RemoveGrade(Predicate <Grade> p) { var gradeSatisfy = Grades.Where(p.Invoke).ToArray(); foreach (var grade in gradeSatisfy) { Grades.Remove(grade); } Save(); if (GradesChanged != null) { GradesChanged.Invoke(); } }
public void EditGrade(Grade grade) { if (grade == null) { throw new ArgumentNullException(); } foreach (var gradeInList in Grades.Where(gradeInList => gradeInList.Equals(grade))) { gradeInList.Mark = grade.Mark; } Save(); if (GradesChanged != null) { GradesChanged.Invoke(); } }
public void AddGrade(Grade grade) { if (grade == null) { throw new ArgumentNullException(); } //Method List<T>.Contains(T obj) uses the overriden Equals methods for objects Grade and Course, therefore it is eligible if (Grades.Contains(grade)) { throw new ArgumentException(); } grade.Id = _idHolder++; Grades.Add(grade); Save(); if (GradesChanged != null) { GradesChanged.Invoke(); } }