Exemple #1
0
 public async Task<ActionResult> DeleteConfirmed(int id)
 {
     imovel imovel = await db.Imovel.FindAsync(id);
     db.Imovel.Remove(imovel);
     await db.SaveChangesAsync();
     return RedirectToAction("Index");
 }
Exemple #2
0
 public async Task<ActionResult> Edit([Bind(Include = "Codigo,Tipo,Valor,Detalhes,Anunciante,Telefone")] imovel imovel)
 {
     if (ModelState.IsValid)
     {
         db.Entry(imovel).State = EntityState.Modified;
         await db.SaveChangesAsync();
         return RedirectToAction("Index");
     }
     return View(imovel);
 }
Exemple #3
0
        public async Task<ActionResult> Create([Bind(Include = "Codigo,Tipo,Valor,Detalhes,Anunciante,Telefone")] imovel imovel)
        {
            if (ModelState.IsValid)
            {
                db.Imovel.Add(imovel);
                await db.SaveChangesAsync();
                return RedirectToAction("Index");
            }

            return View(imovel);
        }
Exemple #4
0
 // GET: imovels/Details/5
 public async Task<ActionResult> Details(int? id)
 {
     if (id == null)
     {
         return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
     }
     imovel imovel = await db.Imovel.FindAsync(id);
     if (imovel == null)
     {
         return HttpNotFound();
     }
     return View(imovel);
 }
Exemple #5
0
        protected void carregaGaleria()
        {
            List <string> lista = new List <string>();
            imovel        imo   = new imovel();

            imo = (new ImovelDominio()).SelecionarImovel(int.Parse(Request.QueryString["id"]));
            List <imovel> listaimo = (new ImovelDominio()).listarUmImovelParaEnganar(int.Parse(Request.QueryString["id"]));

            //for (int i = 1; i < 5; i++)
            //{
            //lista.Add(imo.imagem1.ToString() + i.ToString());
            // lista.Add("imagem" + i.ToString());

            //}
            lvGaleria.DataSource = listaimo;
            lvGaleria.DataBind();
        }
        protected void btnInteresse_Click(object sender, EventArgs e)
        {//tenho que validar o CPF do caboclo, não deixar ele se cadastrar caso não exista na base, e usar o CPF para pesquisar ele na hora de colocar o imóvel no nome dele
            if (txtBairro.Text != null && txtAreaTotalConstruida.Text != null && txtAreaTotal.Text != null &&
                txtCEP.Text != null && txtNumero.Text != null &&
                txtQuartos.Text != null && txtRua.Text != null)
            {
                pessoa          pes     = new pessoa();
                PessoaDominio   pesdom  = new PessoaDominio();
                ImovelDominio   imodom  = new ImovelDominio();
                EnderecoDominio enddom  = new EnderecoDominio();
                string          caminho = " ";
                pes = pesdom.selecionarPessoacomCPF(txtCPFCliente.Text);
                if (pes != null)
                {
                    imovel   imo = new imovel();
                    endereco end = new endereco();
                    end.bairro     = txtBairro.Text;
                    end.cep        = txtCEP.Text;
                    end.logradouro = txtRua.Text;
                    end.numero     = int.Parse(txtNumero.Text);
                    end.cidade     = int.Parse(selCidade.SelectedValue);
                    //tenho que adicionar o endereco antes
                    enddom.AdicionarEndereco(end);
                    //apos isso o imovel(e cliente, que já tenho o objeto carregado graças ao pes)
                    imo.areacon          = txtAreaTotalConstruida.Text;
                    imo.areater          = txtAreaTotal.Text;
                    imo.idcategoria      = int.Parse(selCategoria.SelectedValue);
                    imo.idproprietario   = pesdom.selecionarCliente(pes).id;
                    imo.publicacaostatus = "Não publicar";
                    imo.qtdquartos       = int.Parse(txtQuartos.Text);
                    imo.finalidade       = selFinalidade.SelectedValue;
                    imo.idendereco       = enddom.selecionarUltimoEnderecoID(end);
                    imodom.adicionarImovel(imo);

                    if (fileFotos.HasFiles)
                    {
                        int i = 1;
                        foreach (HttpPostedFile fotos in fileFotos.PostedFiles)
                        {
                            if (i == 1)
                            {
                                FileInfo info = new FileInfo(fotos.FileName);
                                caminho     = Server.MapPath("~" + @"\imoveis\" + info.Name);
                                imo.imagem1 = info.Name;



                                fotos.SaveAs(caminho);
                            }
                            if (i == 2)
                            {
                                FileInfo info = new FileInfo(fotos.FileName);
                                caminho = Server.MapPath("~" + @"\imoveis\" + info.Name);
                                if (info.Name != null)
                                {
                                    imo.imagem2 = info.Name;
                                    //File.Copy(info.Name, caminho);
                                    fotos.SaveAs(caminho);
                                }
                            }
                            if (i == 3)
                            {
                                FileInfo info = new FileInfo(fotos.FileName);
                                caminho = Server.MapPath("~" + @"\imoveis\" + info.Name);
                                if (info.Name != null)
                                {
                                    imo.imagem3 = info.Name;
                                    fotos.SaveAs(caminho);
                                }
                            }
                            if (i == 4)
                            {
                                FileInfo info = new FileInfo(fotos.FileName);
                                caminho = Server.MapPath("~" + @"\imoveis\" + info.Name);
                                if (info.Name != null)
                                {
                                    imo.imagem4 = info.Name;
                                    fotos.SaveAs(caminho);
                                }
                            }
                            i++;
                        }
                        imodom.adicionarImagemAoImovel(imo);
                    }
                    txtBairro.Text = "";
                    txtAreaTotalConstruida.Text = "";
                    txtAreaTotal.Text           = "";
                    txtCEP.Text     = "";
                    txtNumero.Text  = "";
                    txtQuartos.Text = "";
                    txtRua.Text     = "";
                    aviso.Text      = "Imovel enviado !";
                }
                aviso.Text = "Entre em contato conosco para se cadastrar como cliente ou escreva um CPF valido !";
            }
            aviso.Text = "Preencha todos os campos !";
        }