Exemplo n.º 1
0
        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));
        }