public void IncluirConta() { ContaPersistence cp = new ContaPersistence(); Conta c = new Conta(); c.IdGrupo = 2; c.TipoConta = "D"; c.Descricao = "ÁGUA"; int i = cp.Inserir(c); Assert.IsTrue(i > 0); }
public JsonResult Incluir(string descricao) { var _cod = -1; var _msg = ""; try { if (descricao.Trim().Length > 0) { ContaPersistence cp = new ContaPersistence(); if (cp.ObterPorDescricao(descricao).Count > 0) { _msg = "A Conta " + descricao + " já está cadastrada"; } else { cp.Inserir(new Conta() { Descricao = descricao }); _cod = 1; _msg = "A Conta <strong>" + descricao + "</strong> foi cadastrada com sucesso"; } } else { _msg = "A Conta deve ser preenchida"; } } catch (Exception ex) { return(Json(new { cod = _cod, msg = ex.Message }, JsonRequestBehavior.AllowGet)); } return(Json(new { cod = _cod, msg = _msg }, JsonRequestBehavior.AllowGet)); }