public ActionResult BuscarPorFiltro(Modelo.EmpresaFiltro filtro) { string sMsg = string.Empty; bool isSucesso = false; string sHtml = string.Empty; try { if (!string.IsNullOrWhiteSpace(filtro.fCnpj)) { filtro.fCnpj = filtro.fCnpj.Replace("-", "").Replace(".", "").Replace("/", ""); } var dados = JsonConvert.SerializeObject(filtro); HttpCookie cookie = new HttpCookie(CookieName); cookie.Value = dados; cookie.Expires = DateTime.Now.AddDays(30); Response.Cookies.Add(cookie); sHtml = GetHtmlLista(filtro); isSucesso = true; } catch (Exception ex) { sMsg = ex.Message; } var _json = Json(new { sucesso = isSucesso, msg = sMsg, PartialViewHtml = sHtml }, JsonRequestBehavior.AllowGet); _json.MaxJsonLength = int.MaxValue; return(_json); }
private StaticPagedList <Modelo.EmpresaModelo> GetEntidades(Modelo.EmpresaFiltro filtro = null, int Pagina = 1) { if (filtro == null) { filtro = new Modelo.EmpresaFiltro(); if (Request.Cookies[CookieName] != null) { HttpCookie cookie = Request.Cookies[CookieName]; if (!string.IsNullOrWhiteSpace(cookie.Value)) { filtro = JsonConvert.DeserializeObject <Modelo.EmpresaFiltro>(cookie.Value); } } } filtro.Pagina = Pagina; return(regra.BuscarPorFiltro(filtro)); }
private string GetHtmlLista(Modelo.EmpresaFiltro filtro = null, int Pagina = 1) { return(RenderPartialViewToString(_PartialLista, GetEntidades(filtro, Pagina))); }