Ejemplo n.º 1
0
        public async Task <IHttpActionResult> GetByLocal(Guid localId, int?page = 1, int?pageSize = 10)
        {
            var pagedSet = new PaginationSet <ImagenLocalDto>();

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

                    var dbEvaluations = _localService.GetImages(localId, currentPage > 0 ? currentPage - 1 : currentPage, currentPageSize);
                    var evaluations   = Mapper.Map <PagedList <ImagenLocal>, PagedList <ImagenLocalDto> >(dbEvaluations);

                    pagedSet = new PaginationSet <ImagenLocalDto>
                    {
                        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));
        }