public JsonResult BeneficiariosList(int jtStartIndex = 0, int jtPageSize = 0, string jtSorting = null) { try { int qtd = 0; string campo = string.Empty; string crescente = string.Empty; string[] array = jtSorting.Split(' '); if (array.Length > 0) { campo = array[0]; } if (array.Length > 1) { crescente = array[1]; } List <Beneficiarios> beneficiarios = new BoBeneficarios().Pesquisa(jtStartIndex, jtPageSize, campo, crescente.Equals("ASC", StringComparison.InvariantCultureIgnoreCase), out qtd); //Return result to jTable return(Json(new { Result = "OK", Records = beneficiarios, TotalRecordCount = qtd })); } catch (Exception ex) { return(Json(new { Result = "ERROR", Message = ex.Message })); } }
public JsonResult Alterar(BeneficiariosModel model) { BoBeneficarios bo = new BoBeneficarios(); if (!this.ModelState.IsValid) { List <string> erros = (from item in ModelState.Values from error in item.Errors select error.ErrorMessage).ToList(); Response.StatusCode = 400; return(Json(string.Join(Environment.NewLine, erros))); } else { bo.Alterar(new Beneficiarios() { Id = model.Id, Nome = model.Nome, CPF = model.CPF }); return(Json("Cadastro alterado com sucesso")); } }
public ActionResult Alterar(long id) { BoBeneficarios bo = new BoBeneficarios(); Beneficiarios beneficiarios = bo.Consultar(id); Models.BeneficiariosModel model = null; if (beneficiarios != null) { model = new BeneficiariosModel() { Id = beneficiarios.Id, Nome = beneficiarios.Nome, CPF = beneficiarios.CPF }; } return(View(model)); }