public JsonResult Gethistorial(Guid?parent, int page = 1, int limit = 10) { PagedList <EvaluacionDto> items = new PagedList <EvaluacionDto>(); var records = new List <EvaluacionDto>(); long total = 0; if (parent.HasValue) { var parentId = parent.Value; var cadena = _cadenaService.Get(parentId); if (cadena != null) { items = _evaluacionService.GetByCadenaPagedList(cadena.Id, page > 0 ? page - 1 : page, limit); } else { var local = _localService.Get(parentId); if (local != null) { items = _evaluacionService.GetByLocalPagedList(local.Id, page > 0 ? page - 1 : page, limit); } } if (items != null) { records = items.Items; total = items.TotalCount; } } return(Json( new { records, total } , JsonRequestBehavior.AllowGet)); }
public async Task <IHttpActionResult> Get(Guid cadenaId, int?page = 1, int?pageSize = 10) { var pagedSet = new PaginationSet <EvaluacionDto>(); try { if (await _authorizationService.AuthorizeAsync(User)) { var currentPage = page.Value; var currentPageSize = pageSize.Value; var evaluations = _evaluacionService.GetByCadenaPagedList(cadenaId, currentPage > 0 ? currentPage - 1 : currentPage, currentPageSize); pagedSet = new PaginationSet <EvaluacionDto> { 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)); }