示例#1
0
        public async Task <IHttpActionResult> GetByEvaluation(Guid evaluationId, int?page = 1, int?pageSize = 10)
        {
            var pagedSet = new PaginationSet <ImagenEvaluacionDto>();

            try
            {
                if (await _authorizationService.AuthorizeAsync(User))
                {
                    var currentPage     = page.Value;
                    var currentPageSize = pageSize.Value;

                    var dbEvaluations = _evaluacionService.GetImages(evaluationId, currentPage > 0 ? currentPage - 1 : currentPage, currentPageSize);
                    var evaluations   = Mapper.Map <PagedList <ImagenEvaluacion>, PagedList <ImagenEvaluacionDto> >(dbEvaluations);

                    pagedSet = new PaginationSet <ImagenEvaluacionDto>
                    {
                        Page       = currentPage,
                        TotalCount = (int)evaluations.TotalCount,
                        TotalPages = evaluations.TotalPages,
                        Items      = evaluations.Items
                    };
                }
                else
                {
                    var codeResult = new CodeResultStatus(401);
                    return(Ok(codeResult));
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }

            return(Ok(pagedSet));
        }