예제 #1
0
 public void Salvar(Area area)
 {
     if (area.Id > 0)
     {
         Alterar(area);
     }
     Inserir(area);
 }
예제 #2
0
 public ActionResult CadastroArea(Area area)
 {
     if (ModelState.IsValid)
     {
         areaaplicacao.Salvar(area);
         return RedirectToAction("ListaCategoria");
     }
     return View(area);
 }
예제 #3
0
        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;
        }
예제 #4
0
 public void Inserir(Area area)
 {
     var strQuery = string.Format("INSERT INTO AREA (Area) VALUES('{0}')",area.Nome);
     contextoArea.ExecutaComando(strQuery);
 }
예제 #5
0
 public void Alterar(Area area)
 {
     var strQuery = string.Format("UPDATE Area SET Area = '{0}'  WHERE idArea ='{1}'", area.Nome,area.Id);
     contextoArea.ExecutaComando(strQuery);
 }
예제 #6
0
 public ActionResult EditarArea(Area area)
 {
     if(ModelState.IsValid)
     {
         areaaplicacao.Alterar(area);
         return RedirectToAction("ListaCategoria");
     }
     return View(area);
 }