public JsonResult Consultar() { string sBusca = Request.Params["sBusca"].ToString().ToUpper(); string sStatus = Request.Params["sStatus"].ToString(); List <FormaPagamentoViewModelConsulta> lista = new List <FormaPagamentoViewModelConsulta>(); try { FormaPagamentoPersistence fpp = new FormaPagamentoPersistence(); foreach (var item in fpp.ListarTodos().ToList()) { FormaPagamentoViewModelConsulta fp = new FormaPagamentoViewModelConsulta(); fp.Id = item.Id; fp.Descricao = item.Descricao; fp.Status = item.Status; if (item.Status.Equals("A")) { fp.DescricaoStatus = Status.A.ObterDescricao(); } else if (item.Status.Equals("I")) { fp.DescricaoStatus = Status.I.ObterDescricao(); } else { fp.DescricaoStatus = "Valor Desconhecido"; } lista.Add(fp); } ; if (sBusca.Trim().Length > 0) { lista = lista.Where(f => f.Descricao.Trim().ToUpper().Contains(sBusca.Trim().ToUpper())).ToList(); } if (sStatus.Length > 0 && !sStatus.Equals("-1")) { lista = lista.Where(f => f.Status.Equals(sStatus)).ToList(); } } catch (Exception ex) { return(Json(ex.Message, JsonRequestBehavior.AllowGet)); } return(Json(new { aaData = lista }, JsonRequestBehavior.AllowGet)); }
public JsonResult FormaPagamento() { ArrayList lista = new ArrayList(); try { FormaPagamentoPersistence fpp = new FormaPagamentoPersistence(); foreach (var item in fpp.ListarTodos().ToList()) { lista.Add(new KeyValuePair <string, string>(item.Id.ToString(), item.Descricao.ToString())); } } catch (Exception ex) { return(Json(ex.Message, JsonRequestBehavior.AllowGet)); } return(Json(lista, JsonRequestBehavior.AllowGet)); }