Ejemplo n.º 1
0
        public async Task <Result <ListResultDto <TeacherItemDto> > > GetTeachers(GetTeachersInput input)
        {
            var query = _teacherRespository.GetAllIncluding(
                teach => teach.TeacherStudyGroups);

            if (input.AcademicSubjectId.HasValue)
            {
                query = query.Where(teach => teach.AcademicSubjectId == input.AcademicSubjectId.Value);
            }
            var teachers = await query.ToListAsync();

            if (input.StudyGroupId.HasValue)
            {
                teachers = teachers.Where(teacher => teacher.TeacherStudyGroups.Any(
                                              teachStudyGroup => teachStudyGroup.StudyGroupId == input.StudyGroupId)).ToList();
            }

            var teacherDtos = new List <TeacherItemDto>();

            foreach (var teacher in teachers)
            {
                var teacherDto = await MapEntityToEntityDto(teacher);

                var firstFindedDto = teacherDtos.FirstOrDefault(teach => teach.Id == teacherDto.Id);
                if (firstFindedDto == null)
                {
                    teacherDtos.Add(teacherDto);
                }
            }
            return(Result <ListResultDto <TeacherItemDto> > .Success(new ListResultDto <TeacherItemDto>(teacherDtos)));
        }
Ejemplo n.º 2
0
        //列表数据
        public ActionResult GetTeacherDataList(int pIndex = 1)
        {
            ViewBag.pageName = "GetTeacherDataList";
            var input = new GetTeachersInput {
                SkipCount = (pIndex - 1) * PageSize, MaxResultCount = PageSize
            };
            var pagedata = teachersService.GetPagedTeacherss(input);

            GetPageData(pagedata.TotalCount);
            return(PartialView("Shared/TeacherDataList", pagedata.Items));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 根据查询条件获取内训师分页列表
        /// </summary>
        public PagedResultDto <TeachersListDto> GetPagedTeacherss(GetTeachersInput input)
        {
            var query = from tear in _teachersRepository.GetAll()
                        join depart in _departmentRepository.GetAll() on tear.DepartmentId equals depart.DepartmentId into dti
                        join course in _courseInfoRepository.GetAll() on tear.Id equals course.TeacherId into programs
                        select new TeachersListDto
            {
                Id             = tear.Id,
                SysNo          = tear.SysNo,
                UserName       = tear.UserName,
                UserPhone      = tear.UserPhone,
                UserEmail      = tear.UserEmail,
                DepartmentId   = tear.DepartmentId,
                DepartmentName = dti.FirstOrDefault().DisplayName,
                JobpostId      = tear.JobpostId,
                Role           = tear.Role,
                Status         = tear.Status,
                PortraitUrl    = tear.PortraitUrl,
                SpeakerCourse  = tear.SpeakerCourse,
                CreationTime   = tear.CreationTime,
                TrainCount     = programs.Count()
            };
            //TODO:根据传入的参数添加过滤条件

            var teachersCount = query.Count();

            var teacherss = query
                            .OrderByDescending(t => t.CreationTime)
                            .PageBy(input)
                            .ToList();

            var teachersListDtos = teacherss.MapTo <List <TeachersListDto> >();

            return(new PagedResultDto <TeachersListDto>(
                       teachersCount,
                       teachersListDtos
                       ));
        }
Ejemplo n.º 4
0
        public async Task <PagedResultOutput <TeacherListDto> > GetTeachers(GetTeachersInput input)
        {
            var totalcount = await _teacherRepository.CountAsync(x => !x.IsDeleted);

            var query = _teacherRepository.GetAll();

            if (!string.IsNullOrEmpty(input.KeyWord))
            {
                query = query.Where(x =>
                                    x.Surname.Contains(input.KeyWord) ||
                                    x.UserName.Contains(input.KeyWord) ||
                                    x.TeacherNo.Contains(input.KeyWord));
            }

            query = query.OrderBy(x => x.CreationTime)
                    .Skip(input.Start).Take(input.PageSize);

            var teachers = await Task.FromResult(query.ToList());

            return(new PagedResultOutput <TeacherListDto>(totalcount,
                                                          teachers.MapTo <List <TeacherListDto> >()
                                                          ));
        }
 public GetTeachersViewModel()
 {
     Input = new GetTeachersInput();
     Value = new ListResultDto <TeacherItemDto>();
 }