public ActionResult Search(string filter, int? page, int? pagesize) { try { LogBLL.Insert(new LogDado("Search", "Cidade", _idUsuario)); using (var db = new Context()) { var _bll = new BLL.CidadeBLL(db, _idUsuario); var result = _bll.Search(filter, page, pagesize); return View("Index", result); } } catch (Exception ex) { this.AddFlashMessage(RP.Util.Exception.Message.Get(ex), FlashMessage.ERROR); RP.Util.Entity.ErroLog.Add(ex, Session.SessionID, _idUsuario); return RedirectToAction("Index"); } }
public JsonResult JsSearch(string filter, int? page, int? pagesize) { try { using (var db = new Context()) { var _bll = new BLL.CidadeBLL(db, _idUsuario); var result = _bll.Search(filter, page, pagesize); var list = result.Select(s => new { s.idCidade, s.nome, estado = s.Estado.nome, pais = s.Estado.Pais.nome }); return Json(new Util.Class.JsonCollection { result = list, count = result.TotalCount }, JsonRequestBehavior.AllowGet); } } catch (Exception ex) { Response.StatusCode = 500; return Json(RP.Util.Exception.Message.Get(ex), JsonRequestBehavior.AllowGet); } }