public ServiceResponse <List <LessonStudent> > GetLessonStudents(LessonStudentFilterModel filter)
        {
            var response = new ServiceResponse <List <LessonStudent> >();

            response.IsSucceeded = true;

            response.RecordsTotal    = lessonStudentRepository.ListQueryable.Count();
            response.RecordsFiltered = lessonStudentRepository.ListQueryable.AddSearchFilters(filter).Count();
            response.Result          = lessonStudentRepository.ListQueryable.AddSearchFilters(filter).AddOrderAndPageFilters(filter).ToList();
            return(response);
        }
        public IActionResult GetLessonStudents(LessonStudentFilterModel model)
        {
            try

            {
                var result = _LessonStudentService.GetLessonStudents(model);
                if (result.IsSucceeded)
                {
                    return(Ok(result.Result));
                }
                return(BadRequest(result.ErrorMessage));
            }
            catch (Exception e)
            {
                return(BadRequest(e.Message));
            }
        }
예제 #3
0
        public static IQueryable <LessonStudent> AddSearchFilters(this IQueryable <LessonStudent> input, LessonStudentFilterModel filter)
        {
            if (filter != null)
            {
                //    if (filter.Term?.Length > 0)
                //    {
                //        input = input.Where(x => x.Name.Contains(filter.Term));
                //    }

                if (filter.LessonId > 0)
                {
                    input = input.Where(x => x.LessonId == filter.LessonId);
                }

                if (filter.StudentId > 0)
                {
                    input = input.Where(x => x.StudentId == filter.StudentId);
                }
                //if (filter.NameTerm?.Length > 0)
                //{
                //    input = input.Where(x => x.Name.ToLower().Contains(filter.NameTerm.ToLower()));
                //}
                //if (filter.SurNameTerm?.Length > 0)
                //{
                //    input = input.Where(x => !x.SurName.ToLower().Contains(filter.SurNameTerm.ToLower()));
            }

            return(input);
        }