public void Salvar(Area area) { if (area.Id > 0) { Alterar(area); } Inserir(area); }
public ActionResult CadastroArea(Area area) { if (ModelState.IsValid) { areaaplicacao.Salvar(area); return RedirectToAction("ListaCategoria"); } return View(area); }
private List<Area> TransformaReaderEmListaArea(SqlDataReader reader) { var listaDeArea = new List<Area>(); while (reader.Read()) { var tempArea = new Area(); tempArea.Id = int.Parse(reader["idArea"].ToString()); tempArea.Nome = reader["Area"].ToString(); listaDeArea.Add(tempArea); } reader.Close(); return listaDeArea; }
public void Inserir(Area area) { var strQuery = string.Format("INSERT INTO AREA (Area) VALUES('{0}')",area.Nome); contextoArea.ExecutaComando(strQuery); }
public void Alterar(Area area) { var strQuery = string.Format("UPDATE Area SET Area = '{0}' WHERE idArea ='{1}'", area.Nome,area.Id); contextoArea.ExecutaComando(strQuery); }
public ActionResult EditarArea(Area area) { if(ModelState.IsValid) { areaaplicacao.Alterar(area); return RedirectToAction("ListaCategoria"); } return View(area); }