Ejemplo n.º 1
0
        private void ConfigureGrid(PagedList <ClienteListDTO> pagedList)
        {
            try
            {
                //var deserializado = JsonConvert.DeserializeObject<dynamic>(pagedList.Adicional, new[] { new StringToNIntConverter() });
                //int? parametro = deserializado.EscolaId != null && !string.IsNullOrEmpty(deserializado.Parametro.Value as string) ? deserializado.Parametro : null;
                //pagedList.Adicional = JsonConvert.SerializeObject(deserializado);


                //Definindo a action da GridPartial
                pagedList.Action = "IndexGrid";

                //Obtenha a quantidade total de registros
                var totalRecords = (int)_clienteService.CountClientes(pagedList.SearchTerm);

                //Obtenha os registros
                IList <ClienteListDTO> entities = null;

                if (pagedList.Sort == "RazaoSocial")
                {
                    entities = _clienteService.FindClientes(pagedList.SearchTerm, c => c.RazaoSocial, pagedList.SortAsc, pagedList.Page, pagedList.PageSize);
                }
                else if (pagedList.Sort == "Cnpj")
                {
                    entities = _clienteService.FindClientes(pagedList.SearchTerm, c => c.Cnpj, pagedList.SortAsc, pagedList.Page, pagedList.PageSize);
                }
                else if (pagedList.Sort == "TipoEmpresa")
                {
                    entities = _clienteService.FindClientes(pagedList.SearchTerm, c => c.TipoEmpresa, pagedList.SortAsc, pagedList.Page, pagedList.PageSize);
                }
                else
                {
                    entities = _clienteService.FindClientes(pagedList.SearchTerm, c => c.NomeFantasia, pagedList.SortAsc, pagedList.Page, pagedList.PageSize);
                }

                //Defina os valores
                pagedList.Parametros(this, entities, totalRecords);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }