Beispiel #1
0
        public List <ImovelModel> listarImoveisAluguel()
        {
            List <ImovelModel> lista          = new List <ImovelModel>();
            DateTime           hoje           = DateTime.Today;
            DateTime           DoisMesesAtras = hoje.AddMonths(-2);

            using (ImobGentilEntities db = new ImobGentilEntities())
            {
                lista = (from i in db.imovel
                         join cli in db.cliente on i.idcliente equals cli.id
                         join vis in db.visita on i.id equals vis.idimovel
                         join loc in db.locacoes on vis.id equals loc.idvisita
                         from pag in db.pagamentos where loc.id == pag.idlocacoes && i.finalidade == "Aluguel" && pag.datap > DoisMesesAtras

                         select new ImovelModel()
                {
                    id = i.id,
                    clienteNome = cli.pessoa.nome,
                    finalidade = i.finalidade,
                    dataultimopagamento = pag.datap.Value,
                    idLocacao = loc.id,
                }).ToList();
            }
            return(lista);
        }
Beispiel #2
0
        public CorretorModel selecionarCorretor(int id)
        {
            CorretorModel corretor = new CorretorModel();

            using (ImobGentilEntities db = new ImobGentilEntities())
            {
                corretor = (from cor in db.corretor
                            where cor.id == id
                            join pes in db.pessoa on cor.idpessoa equals pes.id
                            join end in db.endereco on pes.idendereco equals end.id
                            select new CorretorModel()
                {
                    Nome = pes.nome,
                    CPF = pes.cpf,
                    celular = pes.celular,
                    cidade = end.City.Name,
                    estado = end.City.State.Name,
                    logradouro = end.logradouro,
                    numero = end.numero.Value,
                    telefone = pes.telefone,
                    bairro = end.bairro,
                    CEP = end.cep,
                    email = pes.email,
                }).First();
            }
            return(corretor);
        }
Beispiel #3
0
        //public visita selecionarVisita(int idvisita)
        //{

        //}
        public List <VisitaModel> listarTodasVisitas()
        {
            List <VisitaModel> lista = new List <VisitaModel>();

            using (ImobGentilEntities db = new ImobGentilEntities())
            {
                lista = (from vis in db.visita
                         where vis.resultado == "Pendente"
                         select new VisitaModel()
                {
                    corretorcomissao = vis.corretorcomissao.Value,
                    data = vis.data.Value,
                    hora = vis.hora,
                    id = vis.id,
                    idcliente = vis.idcliente.Value,
                    idcorretor = vis.idcorretor.Value,
                    idimovel = vis.idimovel.Value,
                    resultado = vis.resultado,
                    status = vis.status,
                }).ToList();
            }


            return(lista);
        }
Beispiel #4
0
 public void modificarPermissao(permissoes per)
 {
     using (ImobGentilEntities db = new ImobGentilEntities())
     {
         db.Entry(per).State = System.Data.EntityState.Modified;
         db.SaveChanges();
     }
 }
Beispiel #5
0
 public void adicionarRegistroPermissaoParaNovoUsuario(permissoes per)
 {
     using (ImobGentilEntities db = new ImobGentilEntities())
     {
         db.permissoes.Add(per);
         db.SaveChanges();
     }
 }
Beispiel #6
0
 public void adicionarImovel(imovel imo)
 {
     using (ImobGentilEntities db = new ImobGentilEntities())
     {
         db.imovel.Add(imo);
         db.SaveChanges();
     }
 }
Beispiel #7
0
 public void adicionarVenda(vendas ven)
 {
     using (ImobGentilEntities db = new ImobGentilEntities())
     {
         db.vendas.Add(ven);
         db.SaveChanges();
     }
 }
Beispiel #8
0
 public void adicionarImagemAoImovel(imovel imo)
 {
     using (ImobGentilEntities db = new ImobGentilEntities())
     {
         db.Entry(imo).State = System.Data.EntityState.Modified;
         db.SaveChanges();
     }
 }
Beispiel #9
0
 public void adicionarPagamento(pagamentos pag)
 {
     using (ImobGentilEntities db = new ImobGentilEntities())
     {
         db.pagamentos.Add(pag);
         db.SaveChanges();
     }
 }
Beispiel #10
0
 public void alterarCorretorVendasAluguel(corretor cor)
 {
     using (ImobGentilEntities db = new ImobGentilEntities())
     {
         db.Entry(cor).State = System.Data.EntityState.Modified;
         db.SaveChanges();
     }
 }
Beispiel #11
0
 public void adicionarImagemGaleria(imagem img)
 {
     using (ImobGentilEntities db = new ImobGentilEntities())
     {
         db.imagem.Add(img);
         db.SaveChanges();
     }
 }
Beispiel #12
0
        //public List<object> listarCorretoresPorCategoria(pessoa pes, int categoria)
        //{

        //    List<object> list = new List<object>();

        //    using (ImobGentilEntities db = new ImobGentilEntities())
        //    {//descobrir como fazer essa merda hoje
        //        list = (from e in db.especializacao
        //                join cor in db.corretor on e.idcorretor equals cor.id
        //                join pessoa in db.pessoa on cor.idpessoa equals pessoa.id
        //                join cat in db.categoria on e.idcategoria equals cat.id
        //                select new { pessoa.nome, pessoa.telefone }).ToList();
        //        //list = (from p in db.corretor where pes.id == p.id select p).ToList();
        //        return list;
        //    }

        //}

        public corretor selecionarCorretor(pessoa pes)
        {
            corretor cor;

            using (ImobGentilEntities db = new ImobGentilEntities())
            {
                cor = (from p in db.corretor where pes.id == p.id select p).FirstOrDefault();
                return(cor);
            }
        }
Beispiel #13
0
        public endereco selecionarEnderecoComRuaeNumero(string logradouro, int numero)
        {
            endereco end = new endereco();

            using (ImobGentilEntities db = new ImobGentilEntities())
            {
                end = (from e in db.endereco where e.logradouro.Contains(logradouro) && e.numero == numero orderby e.id descending select e).First();
                return(end);
            }
        }
Beispiel #14
0
        public int SelecionarUltimoCorretor(int idpessoa)
        {
            int id = 0;

            using (ImobGentilEntities db = new ImobGentilEntities())
            {
                id = (from p in db.corretor where idpessoa == p.idpessoa select p.id).FirstOrDefault();
                return(id);
            }
        }
Beispiel #15
0
        public cliente selecionarCliente(pessoa pes)
        {
            cliente cli;

            using (ImobGentilEntities db = new ImobGentilEntities())
            {
                cli = (from c in db.cliente where pes.id == c.idpessoa select c).FirstOrDefault();
                return(cli);
            }
        }
Beispiel #16
0
        public pessoa selecionarPessoaRetornarCPF(int id)
        {
            pessoa cli;

            using (ImobGentilEntities db = new ImobGentilEntities())
            {
                cli = (from c in db.pessoa where id == c.id select c).FirstOrDefault();
                return(cli);
            }
        }
Beispiel #17
0
        public int selecionarUltimaPessoaID()
        {
            int id = 0;

            using (ImobGentilEntities db = new ImobGentilEntities())
            {
                id = (from p in db.pessoa select p.id).LastOrDefault();
                return(id);
            }
        }
Beispiel #18
0
        public int selecionarPessoaIDcomCPF(string cpf)
        {
            int id = 0;

            using (ImobGentilEntities db = new ImobGentilEntities())
            {
                id = (from p in db.pessoa where cpf == p.cpf select p.id).FirstOrDefault();
                return(id);
            }
        }
Beispiel #19
0
        public List <corretor> listarCorretores(pessoa pes)
        {
            List <corretor> list = new List <corretor>();

            using (ImobGentilEntities db = new ImobGentilEntities())
            {
                list = (from p in db.corretor where pes.id == p.id select p).ToList();
                return(list);
            }
        }
Beispiel #20
0
        public int selecionarPessoaID(pessoa pes)
        {
            int id = 0;

            using (ImobGentilEntities db = new ImobGentilEntities())
            {
                id = (from p in db.pessoa where pes.id == p.id select p.id).FirstOrDefault();
                return(id);
            }
        }
Beispiel #21
0
        public pessoa selecionarPessoacomCPF(string cpf)
        {
            pessoa pes;

            using (ImobGentilEntities db = new ImobGentilEntities())
            {
                pes = (from p in db.pessoa where cpf == p.cpf select p).FirstOrDefault();
                return(pes);
            }
        }
Beispiel #22
0
        public int selecionarUltimoEnderecoID(endereco end)
        {
            int id = 0;

            using (ImobGentilEntities db = new ImobGentilEntities())
            {
                id = (from e in db.endereco where e.logradouro.Contains(end.logradouro) orderby e.id descending select e.id).First();
                return(id);
            }
        }
Beispiel #23
0
 public int adicionarAluguelRetornaID(locacoes aluguel)
 {
     using (ImobGentilEntities db = new ImobGentilEntities())
     {
         db.locacoes.Add(aluguel);
         db.SaveChanges();
         db.Entry(aluguel).GetDatabaseValues();
         return(aluguel.id);
     }
 }
Beispiel #24
0
        public imovel SelecionarUltimoImovel()
        {
            imovel retorno;

            using (ImobGentilEntities db = new ImobGentilEntities())
            {
                retorno = (from e in db.imovel
                           select e).ToList().Last();
            }
            return(retorno);
        }
Beispiel #25
0
        public locacoes existeAluguel(int idimovel)
        {
            locacoes loca;

            using (ImobGentilEntities db = new ImobGentilEntities())
            {
                loca = (from loc in db.locacoes
                        where loc.visita.idimovel == idimovel
                        select loc).FirstOrDefault();
            }
            return(loca);
        }
Beispiel #26
0
        public vendas existeVenda(int idimovel)
        {
            vendas vend;

            using (ImobGentilEntities db = new ImobGentilEntities())
            {
                vend = (from ven in db.vendas
                        where ven.visita.idimovel == idimovel
                        select ven).FirstOrDefault();
            }
            return(vend);
        }
Beispiel #27
0
        public interesse selecionarInteresseComID(int id)
        {
            interesse inte = new interesse();

            using (ImobGentilEntities db = new ImobGentilEntities())
            {
                inte = (from vi in db.interesse
                        where vi.id == id
                        select vi).FirstOrDefault();
            }
            return(inte);
        }
Beispiel #28
0
        public int pegarIDCategoria(string categoria)
        {
            int id = 0;

            using (ImobGentilEntities db = new ImobGentilEntities())
            {
                id = (from e in db.categoria
                      where e.nome.Contains(categoria)
                      select e.id).FirstOrDefault();
            }
            return(id);
        }
Beispiel #29
0
        public visita selecionarVisitaComID(int id)
        {
            visita vis = new visita();

            using (ImobGentilEntities db = new ImobGentilEntities())
            {
                vis = (from vi in db.visita
                       where vi.id == id
                       select vi).FirstOrDefault();
            }
            return(vis);
        }
Beispiel #30
0
        public List <imovel> listarImovelPorCategoriasemValor(int cat)
        {
            List <imovel> lista = new List <imovel>();

            using (ImobGentilEntities db = new ImobGentilEntities())
            {
                lista = ((from i in db.imovel
                          where i.idcategoria == cat && i.publicacaostatus == "Publicar"
                          select i).ToList());
            }
            return(lista);
        }