コード例 #1
0
        [HttpGet("GetClientes")] // post api/Cliente/GetClientes
        public ActionResult getClientes([FromQuery(Name = "PageNumber")] int PageNumber,
                                        [FromQuery(Name = "Rows")] int Rows)
        {
            ClienteServices clienteServices = new ClienteServices();
            List <Cliente>  lCliente        = clienteServices.returnClientes(PageNumber, Rows);
            int             total           = 0;

            string query = "SELECT COUNT(*) AS 'TOTAL' FROM [adpruebas_de_timbrado].[dbo].[admClientes];";

            string connString = DatabaseServices.GetConnString();

            using (SqlConnection sqlConnection = new SqlConnection(connString))
            {
                SqlCommand cmd = new SqlCommand(query, sqlConnection);
                sqlConnection.Open();
                using (SqlDataReader reader = cmd.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        total = reader.GetInt32(0);
                    }
                }
            }

            ListOfClientes listOfClientes = new ListOfClientes(lCliente, PageNumber, total);
            string         jsonString;

            jsonString = JsonSerializer.Serialize(listOfClientes);
            return(Ok(jsonString));
        }