public ActionResult Create([Bind(Include = "TipoImovelID,NomeTipo")] TipoImovel tipoImovel) { if (ModelState.IsValid) { db.TiposImovel.Add(tipoImovel); db.SaveChanges(); try { string str = Request["pai"]; int PaiId = int.Parse(str); if (PaiId > 0) { TipoImovel TipoPai = db.TiposImovel.Find(PaiId); if (TipoPai != null) { TipoPai.SubTipos.Add(tipoImovel); db.Entry(tipoImovel).State = EntityState.Modified; db.SaveChanges(); } } } catch (Exception) {} return(RedirectToAction("Index")); } return(View(tipoImovel)); }
public ActionResult Editar(int id, TipoImovel tipoImovel) { using (TipoImovelConnection tipoImovels = new TipoImovelConnection()) { tipoImovels.Update(id, tipoImovel); return(RedirectToAction("Index", "TipoImovel")); } }
public ActionResult Cadastrar(TipoImovel estado) { using (TipoImovelConnection tipoImovel = new TipoImovelConnection()) { tipoImovel.Create(estado); return(RedirectToAction("Index", "TipoImovel")); } }
public ActionResult DeleteConfirmed(int id) { TipoImovel tipoImovel = db.TiposImovel.Find(id); db.TiposImovel.Remove(tipoImovel); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Apagar(int id, TipoImovel estado) { using (TipoImovelConnection tipoImovel = new TipoImovelConnection()) { tipoImovel.Delete(id); return(RedirectToAction("Index", "TipoImovel")); } }
public ActionResult Editar(int id) { using (TipoImovelConnection tipoImovel = new TipoImovelConnection()) { ViewBag.Status = Enum.GetValues(typeof(Status)); TipoImovel estado = tipoImovel.Read(id); return(View(estado)); } }
public void Create(TipoImovel tipoImovel) { SqlCommand cmd = new SqlCommand(); cmd.Connection = connection; cmd.CommandText = @"INSERT INTO Tipos_Imoveis VALUES(@Nome, @Status)"; cmd.Parameters.AddWithValue("@Nome", tipoImovel.Nome); cmd.Parameters.AddWithValue("@Status", tipoImovel.Status); cmd.ExecuteNonQuery(); }
public ActionResult Inserir(TipoImovel tipoImovel) { if (ModelState.IsValid) { db.TipoImovel.Add(tipoImovel); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(tipoImovel)); }
public ActionResult Edit([Bind(Include = "TipoImovelID,NomeTipo")] TipoImovel tipoImovel) { if (ModelState.IsValid) { db.Entry(tipoImovel).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(tipoImovel)); }
public ActionResult Alterar(TipoImovel tipoImovel) { if (ModelState.IsValid) { db.Entry(tipoImovel).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(tipoImovel)); }
public Imovel(int cod_imovel, float metro_quadrado, string descricao, int numero_quartos, int numero_banheiros, TipoImovel tipoImovel, int proprietarioRefId, int enderecoRefId) { this.cod_imovel = cod_imovel; this.metro_quadrado = metro_quadrado; this.descricao = descricao; this.numero_quartos = numero_quartos; this.numero_banheiros = numero_banheiros; _tipoImovel = tipoImovel; ProprietarioRefId = proprietarioRefId; EnderecoRefId = enderecoRefId; }
public void Update(int id, TipoImovel tipoImovel) { SqlCommand cmd = new SqlCommand(); cmd.Connection = connection; cmd.CommandText = @"UPDATE Tipos_Imoveis SET nome = @nome, status = @status WHERE id = @id"; cmd.Parameters.AddWithValue("@id", id); cmd.Parameters.AddWithValue("@nome", tipoImovel.Nome); cmd.Parameters.AddWithValue("@status", tipoImovel.Status); cmd.ExecuteNonQuery(); }
public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } TipoImovel tipoImovel = db.TiposImovel.Find(id); if (tipoImovel == null) { return(HttpNotFound()); } return(View(tipoImovel)); }
public ActionResult EfetuarExclusao(int id) { try { TipoImovel tipoImovel = db.TipoImovel.Find(id); db.TipoImovel.Remove(tipoImovel); db.SaveChanges(); return(RedirectToAction("Index")); } catch { return(RedirectToAction("ErroExcluir")); } }
public ActionResult Apagar(int id) { using (TipoImovelConnection tipoImovel = new TipoImovelConnection()) { if (tipoImovel.Check(id)) { ViewBag.Status = Enum.GetValues(typeof(Status)); TipoImovel tipoImovels = tipoImovel.Read(id); return(View(tipoImovels)); } TempData["Erro"] = "O Tipo de Imovel está em uso e não pode ser Excluido!!!"; return(RedirectToAction("Index", "TipoImovel")); } }
public TipoImovel Read(int id) { TipoImovel tipoImovel = new TipoImovel(); SqlCommand cmd = new SqlCommand(); cmd.Connection = connection; cmd.CommandText = @"SELECT * FROM Tipos_Imoveis WHERE id = @id"; cmd.Parameters.AddWithValue("@id", id); SqlDataReader reader = cmd.ExecuteReader(); if (reader.Read()) { tipoImovel.Id = (int)reader["id"]; tipoImovel.Nome = (string)reader["nome"]; tipoImovel.Status = (Status)reader["status"]; } return(tipoImovel); }
public List <TipoImovel> ReadAll() { List <TipoImovel> lista = new List <TipoImovel>(); SqlCommand cmd = new SqlCommand(); cmd.Connection = connection; cmd.CommandText = @"select * from Tipos_Imoveis order by nome"; SqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { TipoImovel tipoImovel = new TipoImovel(); tipoImovel.Id = (int)reader["id"]; tipoImovel.Nome = (string)reader["nome"]; tipoImovel.Status = (Status)reader["status"]; lista.Add(tipoImovel); } return(lista); }
public ActionResult Excluir(int id) { TipoImovel tipoImovel = db.TipoImovel.Find(id); return(View(tipoImovel)); }