public bool isFilteredBySetStatus(Admin admin, int setStatus) { if (setStatus == (int)SetAllotStatus.Allocated) { if (admin.TeacherAllocations.Count == 0) { return(true); } return(false); } else if (setStatus == (int)SetAllotStatus.UnAllocated) { if (admin.TeacherAllocations.Count > 0) { return(true); } return(false); } else if (setStatus == (int)SetAllotStatus.CreditInadequate) { var b = true; foreach (var item in admin.TeacherAllocations) { var sCount = StudentAllocationRepository.Count(e => e.TeacherAllocationId == item.Id); if (item.Credit - sCount == 0) { b = false; } } return(b); } return(true); }
private void Fill(int?setId, int setStatus, IQueryable <Admin> teacherList, PaginationDataList <AdminDto> paginaList) { var studentQueryable = teacherList.SelectMany(e => e.Classes.SelectMany(x => x.Students)); foreach (var teacher in teacherList) { var dto = ObjectMapper.Map <AdminDto>(teacher); dto.Password = null; teacher.Classes.ForEach(e => { dto.StudentCount = dto.StudentCount + studentQueryable.Count(x => x.ClassId == e.Id); dto.ClassName.Add(e.Name); }); if (setId.HasValue && setId.Value != 0) { if (HasTeacherAllocation(teacher, setId.Value)) { continue; } } if (setStatus != 0) { if (isFilteredBySetStatus(teacher, setStatus)) { continue; } } if (teacher.TeacherAllocations.Count == 0) { dto.SetName.Add(HintInfo.UnAllocated); } else { foreach (var teacherAllocation in teacher.TeacherAllocations) { var set = SetRepository.Single(e => e.Id == teacherAllocation.SetId); var count = StudentAllocationRepository.Count(e => e.TeacherAllocationId == teacherAllocation.Id); dto.SetName.Add(set.SetName + "----" + count + "/" + teacherAllocation.Credit); } } paginaList.ListData.Add(dto); } }