public PaginatedList <Staff> SearchStaff(int?schoolYearId, int?classId, int?studentId, string filter, bool orderByFirstName, int start, int count) { var staffs = StaffStorage.GetAll().AsEnumerable(); if (!string.IsNullOrEmpty(filter)) { var words = filter.ToLower().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); staffs = staffs.Where(x => words.Any(w => x.FirstName.ToLower().Contains(w))); } var classTeachers = ServiceLocator.ClassService.GetClassTeachers(null, null); if (classId.HasValue) { classTeachers = classTeachers.Where(x => x.ClassRef == classId.Value).ToList(); } if (studentId.HasValue) { var classPerson = ServiceLocator.ClassService.GetClassPersons(studentId.Value, null); classTeachers = classTeachers.Where(ct => classPerson.Any(cp => cp.ClassRef == ct.ClassRef)).ToList(); } staffs = staffs.Where(st => classTeachers.Any(ct => ct.PersonRef == st.Id)); staffs = orderByFirstName ? staffs.OrderBy(x => x.FirstName) : staffs.OrderBy(x => x.LastName); return(new PaginatedList <Staff>(staffs.ToList(), start / count, count)); }
public Staff GetStaff(int staffId) { return(StaffStorage.GetById(staffId)); }
public IList <Staff> GetStaffs() { return(StaffStorage.GetAll()); }
public void Delete(IList <Staff> staffs) { StaffStorage.Delete(staffs); }
public void Edit(IList <Staff> staffs) { StaffStorage.Update(staffs); }
public void Add(IList <Staff> staffs) { StaffStorage.Add(staffs); }