Ejemplo n.º 1
0
        public async Task <PagedList <Assignment> > GetAssignmentsAsync(Guid enrollmentId,
                                                                        AssignementParametes assignementParametes, bool trackChanges)
        {
            var assignment = await FindByCondition(e => e.EnrollmentId.Equals(enrollmentId), trackChanges)
                             .OrderBy(e => e.Title)
                             .ToListAsync();

            return(PagedList <Assignment>
                   .ToPagedList(assignment, assignementParametes.PageNumber, assignementParametes.PageSize));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> GetAssignmentsForEnrollment(Guid enrollmentId, [FromQuery]
                                                                      AssignementParametes assignementParametes)

        {
            var enrollment = await _repository.Enrollment.GetEnrollmentsAsync(enrollmentId, trackChanges : false);

            if (enrollment == null)
            {
                _logger.LogInfo($"Enrollment with id: {enrollmentId} doesn't exist in the database.");
                return(NotFound());
            }

            var assignmentsFromDb = await _repository.Assignment.GetAssignmentsAsync(enrollmentId, assignementParametes, trackChanges : false);

            Response.Headers.Add("X-Pagination", JsonConvert.SerializeObject(assignmentsFromDb.MetaData));

            var assignmentsDto = _mapper.Map <IEnumerable <AssignmentDto> >(assignmentsFromDb);

            return(Ok(assignmentsDto));
        }