Esempio n. 1
0
        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));
        }
Esempio n. 2
0
 public Staff GetStaff(int staffId)
 {
     return(StaffStorage.GetById(staffId));
 }
Esempio n. 3
0
 public IList <Staff> GetStaffs()
 {
     return(StaffStorage.GetAll());
 }
Esempio n. 4
0
 public void Delete(IList <Staff> staffs)
 {
     StaffStorage.Delete(staffs);
 }
Esempio n. 5
0
 public void Edit(IList <Staff> staffs)
 {
     StaffStorage.Update(staffs);
 }
Esempio n. 6
0
 public void Add(IList <Staff> staffs)
 {
     StaffStorage.Add(staffs);
 }