示例#1
0
 public async Task <ActionResult <Student> > GetAllStudents([FromQuery] StudentFilterDto filterDto, [FromQuery] string sort = "Id")
 {
     SortField <Student>[]   sortFields;
     FilterField <Student>[] filterFields;
     try
     {
         sortFields   = mapper.Map <string, SortField <Student>[]>(sort);
         filterFields = mapper.Map <StudentFilterDto, FilterField <Student>[]>(filterDto);
     }
     catch (ArgumentException ex)
     {
         return(BadRequest(ex.Message));
     }
     return(Ok(await studentRepository.GetAsync(sortFields, filterFields).ToList()));
 }
示例#2
0
        public async Task <IReadOnlyList <StudentDto> > GetStudents(
            StudentFilterDto filter,
            PaginationDto pagination)
        {
            var students = await _uow.Students.GetQuery()
                           .Include(student => student.StudentGroupRelations)
                           .ThenInclude(relation => relation.Group)
                           .Where(student =>
                                  (filter.Gender == null || student.Gender == filter.Gender) &&
                                  (filter.FIO.IsNullOrEmpty() ||
                                   student.LastName.ToUpper().Contains(filter.FIO.ToUpper()) ||
                                   student.FirstName.ToUpper().Contains(filter.FIO.ToUpper()) ||
                                   student.MiddleName.ToUpper().Contains(filter.FIO.ToUpper())
                                  ) &&
                                  (filter.Callsign.IsNullOrEmpty() ||
                                   student.Callsign.ToUpper().Contains(filter.Callsign.ToUpper())
                                  ) &&
                                  (filter.GroupName.IsNullOrEmpty() ||
                                   student.StudentGroupRelations
                                   .Any(relation => relation.Group.Name.ToUpper().Contains(filter.GroupName.ToUpper()))
                                  )
                                  )
                           .Skip(pagination.Skip)
                           .Take(pagination.Take)
                           .Select(student => new StudentDto
            {
                Id         = student.Id,
                FIO        = $"{student.LastName} {student.FirstName}{(student.MiddleName != null ? $" {student.MiddleName}" : "")}",
                Gender     = student.Gender,
                Callsign   = student.Callsign,
                GroupNames = student.StudentGroupRelations
                             .Select(relation => relation.Group.Name)
                             .ToList()
            })
                           .ToListAsync();

            return(students);
        }
示例#3
0
        public async Task <ActionResult <PagedResultDataTransferObject <StudentResponseDataTransferObject> > > GetStudents([FromQuery] PagingDto pagingDto, [FromQuery] StudentFilterDto filterDto, [FromQuery] string sort = "Id")
        {
            SortField <Student>[]   sortFields;
            FilterField <Student>[] filterFields;
            try
            {
                sortFields   = mapper.Map <string, SortField <Student>[]>(sort);
                filterFields = mapper.Map <StudentFilterDto, FilterField <Student>[]>(filterDto);
            }
            catch (Exception ex) when(ex is ArgumentException)
            {
                return(BadRequest(ex.Message));
            }
            var paging      = mapper.Map <PagingDto, Paging>(pagingDto);
            var pagedResult = await studentRepository.GetAsync(paging, sortFields, filterFields);

            return(Ok(CreatePagedResultDto <Student, StudentResponseDataTransferObject>(pagedResult, paging, sort, filterDto)));
        }
示例#4
0
 private string PrepareUrlPage(int pageNumber, int pageLimit, string sortFields, StudentFilterDto filterDto)
 {
     return(Url.Action("GetStudents", new
     {
         pageNumber,
         pageLimit,
         filterDto?.Id,
         filterDto?.Name,
         filterDto?.CourseId,
         sort = sortFields
     }));
 }
示例#5
0
        private PagedResultDataTransferObject <TReturn> CreatePagedResultDto <T, TReturn>(PagedResult <T> result, Paging paging, string sort, StudentFilterDto filterDto)
        {
            const int firstPage = 1;

            return(new PagedResultDataTransferObject <TReturn>()
            {
                PageNumber = paging.PageNumber,
                PageSize = paging.PageLimit,
                TotalNumberOfPages = result.TotalNumberOfPages,
                TotalNumberOfRecords = result.TotalNumberOfRecords,
                Results = mapper.Map <List <T>, List <TReturn> >(result.Results),
                FirstPageUrl = PrepareUrlPage(firstPage, paging.PageLimit, sort, filterDto),
                LastPageUrl = PrepareUrlPage(result.TotalNumberOfPages, paging.PageLimit, sort, filterDto),
                NextPageUrl = paging.PageNumber <result.TotalNumberOfPages ? PrepareUrlPage(paging.PageNumber + 1, paging.PageLimit, sort, filterDto) : null,
                                                     PreviousPageUrl = paging.PageNumber> firstPage ? PrepareUrlPage(paging.PageNumber - 1, paging.PageLimit, sort, filterDto) : null
            });
        }
        public async Task <IActionResult> GetFilterStudentList(JQueryDataTableParamModel param, StudentFilterDto model)
        {
            using (var txscope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled))
            {
                try
                {
                    var parameters = CommonMethod.GetJQueryDatatableParamList(param, GetSortingColumnName(param.iSortCol_0));

                    parameters.Parameters.Insert(0, new SqlParameter("@Fromdate", SqlDbType.DateTime)
                    {
                        Value = Convert.ToDateTime(model.FromDate).ToString("yyyy/MM/dd")
                    });
                    parameters.Parameters.Insert(1, new SqlParameter("@Todate", SqlDbType.DateTime)
                    {
                        Value = Convert.ToDateTime(model.ToDate).ToString("yyyy/MM/dd")
                    });

                    if (model.IsMember == true && model.IsNotMember == false)
                    {
                        parameters.Parameters.Insert(2, new SqlParameter("@MemberShipFilter", SqlDbType.Bit)
                        {
                            Value = true
                        });
                    }
                    //if (model.IsNotMember == true && model.IsMember == false)
                    //{
                    //    parameters.Parameters.Insert(2, new SqlParameter("@MemberShipFilter", SqlDbType.VarChar) { Value = "" });
                    //}
                    if (model.IsNotMember == true && model.IsMember == false)
                    {
                        parameters.Parameters.Insert(2, new SqlParameter("@MemberShipFilter", SqlDbType.Bit)
                        {
                            Value = false
                        });
                    }
                    if (model.IsNotMember == true && model.IsMember == true)
                    {
                        parameters.Parameters.Insert(2, new SqlParameter("@MemberShipFilter", SqlDbType.Bit)
                        {
                            Value = DBNull.Value
                        });
                    }

                    var allList = await _studentService.GetFilterStudentList(parameters.Parameters.ToArray());

                    var total = allList.FirstOrDefault()?.TotalRecords ?? 0;
                    return(Json(new
                    {
                        param.sEcho,
                        iTotalRecords = total,
                        iTotalDisplayRecords = total,
                        aaData = allList
                    }));
                }
                catch (Exception ex)
                {
                    ErrorLog.AddErrorLog(ex, "GetFilterStudentList");
                    return(Json(new
                    {
                        param.sEcho,
                        iTotalRecords = 0,
                        iTotalDisplayRecords = 0,
                        aaData = ""
                    }));
                }
            }
        }
 public IActionResult NoOfQuestionAnswerGradeWise(StudentFilterDto model)
 {
     return(View(model));
 }
        public async Task <IActionResult> GetQAByGrade(JQueryDataTableParamModel param, StudentFilterDto model)
        {
            using (var txscope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled))
            {
                try
                {
                    var parameters = CommonMethod.GetJQueryDatatableParamList(param, GetSortingColumnName(param.iSortCol_0));

                    parameters.Parameters.Insert(0, new SqlParameter("@Fromdate", SqlDbType.DateTime)
                    {
                        Value = Convert.ToDateTime(model.FromDate).ToString("yyyy/MM/dd")
                    });
                    parameters.Parameters.Insert(1, new SqlParameter("@Todate", SqlDbType.DateTime)
                    {
                        Value = Convert.ToDateTime(model.ToDate).ToString("yyyy/MM/dd")
                    });

                    var allList = await _studentService.GetQAByGrade(parameters.Parameters.ToArray());

                    List <QAGradeStudent> qAGradeStudents = new List <QAGradeStudent>();

                    foreach (var item in allList.GroupBy(x => x.GradeName))
                    {
                        QAGradeStudent qAGradeStudent = new QAGradeStudent();
                        qAGradeStudent.GradeName = item.Key;
                        foreach (var item1 in item)
                        {
                            LessonData lessonData = new LessonData();
                            lessonData.LessonName = item1.LessonName;
                            lessonData.QACount    = item1.QACount;
                            qAGradeStudent.Lessons.Add(lessonData);
                        }
                        qAGradeStudents.Add(qAGradeStudent);
                    }

                    var total = allList.FirstOrDefault()?.TotalRecords ?? 0;
                    return(Json(new
                    {
                        param.sEcho,
                        iTotalRecords = total,
                        iTotalDisplayRecords = total,
                        aaData = qAGradeStudents
                    }));
                }
                catch (Exception ex)
                {
                    ErrorLog.AddErrorLog(ex, "GetQAByGrade");
                    return(Json(new
                    {
                        param.sEcho,
                        iTotalRecords = 0,
                        iTotalDisplayRecords = 0,
                        aaData = ""
                    }));
                }
            }
        }
 public IActionResult FilterStudentGradeWise(StudentFilterDto model)
 {
     return(View(model));
 }