コード例 #1
0
        public AnexGRIDResponde Listar(AnexGRID grid)
        {
            IEnumerable<Entities.Articulo> query = new List<Entities.Articulo>();
            //  Entities.Articulo query = null;
            //var context = new ArticuloDbContext();
            using (var con = new SqlConnection(this.ConnectionString))
            {
                query = con.Query<Entities.Articulo>("usp_articulos_get", commandType: System.Data.CommandType.StoredProcedure);

                if (grid.columna == "Id")
                {
                    query = grid.columna_orden == "DESC" ? query.OrderByDescending(x => x.Id)
                                                         : query.OrderBy(x => x.Id);
                }

                if (grid.columna == "Titulo")
                {
                    query = grid.columna_orden == "DESC" ? query.OrderByDescending(x => x.Titulo)
                                                         : query.OrderBy(x => x.Titulo);
                }

                if (grid.columna == "Autor")
                {
                    query = grid.columna_orden == "DESC" ? query.OrderByDescending(x => x.Autor)
                                                         : query.OrderBy(x => x.Autor);
                }

                if (grid.columna == "Contenido")
                {
                    query = grid.columna_orden == "DESC" ? query.OrderByDescending(x => x.Contenido)
                                                         : query.OrderBy(x => x.Contenido);
                }

                if (grid.columna == "Tags")
                {
                    query = grid.columna_orden == "DESC" ? query.OrderByDescending(x => x.Tags)
                                                         : query.OrderBy(x => x.Tags);
                }
                if (grid.columna == "Fecha")
                {
                    query = grid.columna_orden == "DESC" ? query.OrderByDescending(x => x.Fecha)
                                                         : query.OrderBy(x => x.Fecha);
                }

                // id, Nombre, Titulo, Desde, Hasta

                var Articulos = query.Skip(grid.pagina)
                                        .Take(grid.limite)
                                         .ToList();

                var total = query.Count();

                grid.SetData(Articulos, total);

                return grid.responde();
            }
        }
コード例 #2
0
 public JsonResult ListarArticulo(AnexGRID grid )
 {
     return Json(ArticuloService.Listar(grid));
 }