Пример #1
0
        public int InsertForEndosso(Proposta proposta)
        {
            //Adicionando Segurado
            CondutorDAO condutorDao = new CondutorDAO();

            condutorDao.Editar(proposta.Segurado);
            //db.Condutor.Add(proposta.Segurado);
            //db.SaveChanges();

            //Adicionando telefones do segurado
            //SALVANDO telefones do segurado
            List <Telefone> telefonesCorretos = new List <Telefone>();
            TelefoneDAO     telefoneDao       = new TelefoneDAO();

            if (null != proposta.Segurado && proposta.Segurado.Telefones != null)
            {
                foreach (Telefone telefone in proposta.Segurado.Telefones)
                {
                    if (telefone.NumeroTelefone != null)
                    {
                        telefone.CodigoCondutor = proposta.Segurado.Id;
                        telefonesCorretos.Add(telefone);
                        telefoneDao.Editar(telefone);
                    }
                }
            }

            //Adicionando Proprietario
            if (proposta.Proprietario.CodigoCpf != null)
            {
                proposta.Proprietario.IEProprietarioVeiculo = Enumerations.IEProprietarioVeiculo.SIM;
                condutorDao.Editar(proposta.Proprietario);
                //proposta.Proprietario.codigoSegurado = proposta.Segurado.Id;
                //db.Condutor.Add(proposta.Proprietario);
            }

            //Adicionando Outro Condutor
            if (proposta.OutroCondutor.CodigoCpf != null)
            {
                proposta.OutroCondutor.IECondutorPrincipal = Enumerations.IECondutorPrincipal.OUTRAPESSOA;
                condutorDao.Editar(proposta.OutroCondutor);
                //proposta.OutroCondutor.codigoSegurado = proposta.Segurado.Id;
                //db.Condutor.Add(proposta.OutroCondutor);
            }

            //Adicionando Proposta
            //proposta.codigoSegurado = proposta.Segurado.Id;
            int novoIdProposta = db.Proposta.Add(proposta).Id;

            db.SaveChanges();

            ////correção provisoria
            //if(proposta.CodigoCobertura == 0)
            //{
            //    proposta.CodigoCobertura = 1;
            //}
            //db.SaveChanges();
            db.Dispose();
            return(novoIdProposta);
        }
Пример #2
0
        public Proposta GetProposta(int?id)
        {
            Proposta proposta = db.Proposta.Find(id);

            proposta.Cobertura = db.Cobertura.Find(proposta.CodigoCobertura);
            proposta.Segurado  = db.Condutor.Find(proposta.codigoSegurado);


            //obtendo telefone
            TelefoneDAO telefoneDao = new TelefoneDAO();

            proposta.Segurado.Telefones = telefoneDao.ObterTodosPorIdCondutor(proposta.Segurado.Id);

            CondutorDAO condutorDao = new CondutorDAO();

            if (proposta.Segurado.IEProprietarioVeiculo == Enumerations.IEProprietarioVeiculo.NAO)
            {
                proposta.Proprietario = condutorDao.ObterPorIdSeguradoETipo(proposta.Segurado.Id, 1);
            }
            if (proposta.Segurado.IECondutorPrincipal == Enumerations.IECondutorPrincipal.OUTRAPESSOA)
            {
                proposta.OutroCondutor = condutorDao.ObterPorIdSeguradoETipo(proposta.Segurado.Id, 2);
            }

            return(proposta);
        }
Пример #3
0
        public void Save(Proposta proposta)
        {
            //SALVANDO Segurado
            CondutorDAO condutorDao = new CondutorDAO();

            condutorDao.Editar(proposta.Segurado);

            //SALVANDO telefones do segurado
            List <Telefone> telefonesCorretos = new List <Telefone>();
            TelefoneDAO     telefoneDao       = new TelefoneDAO();

            if (proposta.Segurado.Telefones != null)
            {
                foreach (Telefone telefone in proposta.Segurado.Telefones)
                {
                    if (telefone.NumeroTelefone != null)
                    {
                        telefone.CodigoCondutor = proposta.Segurado.Id;
                        telefonesCorretos.Add(telefone);
                        telefoneDao.Editar(telefone);
                    }
                }
            }

            //SALVANDO Proprietario
            if (proposta.Proprietario.CodigoCpf != null)
            {
                proposta.Proprietario.IEProprietarioVeiculo = Enumerations.IEProprietarioVeiculo.SIM;
                proposta.Proprietario.codigoSegurado        = proposta.Segurado.Id;
                condutorDao.Editar(proposta.Proprietario);
            }

            //SALVANDO Outro Condutor
            if (proposta.OutroCondutor.CodigoCpf != null)
            {
                proposta.OutroCondutor.IECondutorPrincipal = Enumerations.IECondutorPrincipal.OUTRAPESSOA;
                proposta.OutroCondutor.codigoSegurado      = proposta.Segurado.Id;
                condutorDao.Editar(proposta.OutroCondutor);
            }


            db.SaveChanges();
            proposta.codigoSegurado = proposta.Segurado.Id;
            Editar(proposta);
            //Insert(proposta);
            //Delete(proposta);
        }
Пример #4
0
        public void Save(Proposta proposta)
        {
            //SALVANDO Segurado
            CondutorDAO condutorDao = new CondutorDAO();
            condutorDao.Editar(proposta.Segurado);

            //SALVANDO telefones do segurado
            List<Telefone> telefonesCorretos = new List<Telefone>();
            TelefoneDAO telefoneDao = new TelefoneDAO();
            if (proposta.Segurado.Telefones != null)
            {
                foreach (Telefone telefone in proposta.Segurado.Telefones)
                {
                    if (telefone.NumeroTelefone != null)
                    {
                        telefone.CodigoCondutor = proposta.Segurado.Id;
                        telefonesCorretos.Add(telefone);
                        telefoneDao.Editar(telefone);
                    }

                }
            }

            //SALVANDO Proprietario
            if (proposta.Proprietario.CodigoCpf != null)
            {
                proposta.Proprietario.IEProprietarioVeiculo = Enumerations.IEProprietarioVeiculo.SIM;
                proposta.Proprietario.codigoSegurado = proposta.Segurado.Id;
                condutorDao.Editar(proposta.Proprietario);
            }

            //SALVANDO Outro Condutor
            if (proposta.OutroCondutor.CodigoCpf != null)
            {
                proposta.OutroCondutor.IECondutorPrincipal = Enumerations.IECondutorPrincipal.OUTRAPESSOA;
                proposta.OutroCondutor.codigoSegurado = proposta.Segurado.Id;
                condutorDao.Editar(proposta.OutroCondutor);
            }

            db.SaveChanges();
            proposta.codigoSegurado = proposta.Segurado.Id;
            Editar(proposta);
            //Insert(proposta);
            //Delete(proposta);
        }
Пример #5
0
        public int InsertForEndosso(Proposta proposta)
        {
            //Adicionando Segurado
            CondutorDAO condutorDao = new CondutorDAO();
            condutorDao.Editar(proposta.Segurado);
            //db.Condutor.Add(proposta.Segurado);
            //db.SaveChanges();

            //Adicionando telefones do segurado
            //SALVANDO telefones do segurado
            List<Telefone> telefonesCorretos = new List<Telefone>();
            TelefoneDAO telefoneDao = new TelefoneDAO();
            if (null != proposta.Segurado && proposta.Segurado.Telefones != null)
            {
                foreach (Telefone telefone in proposta.Segurado.Telefones)
                {
                    if (telefone.NumeroTelefone != null)
                    {
                        telefone.CodigoCondutor = proposta.Segurado.Id;
                        telefonesCorretos.Add(telefone);
                        telefoneDao.Editar(telefone);
                    }

                }
            }

            //Adicionando Proprietario
            if (proposta.Proprietario.CodigoCpf != null)
            {
                proposta.Proprietario.IEProprietarioVeiculo = Enumerations.IEProprietarioVeiculo.SIM;
                condutorDao.Editar(proposta.Proprietario);
                //proposta.Proprietario.codigoSegurado = proposta.Segurado.Id;
                //db.Condutor.Add(proposta.Proprietario);
            }

            //Adicionando Outro Condutor
            if (proposta.OutroCondutor.CodigoCpf != null)
            {
                proposta.OutroCondutor.IECondutorPrincipal = Enumerations.IECondutorPrincipal.OUTRAPESSOA;
                condutorDao.Editar(proposta.OutroCondutor);
                //proposta.OutroCondutor.codigoSegurado = proposta.Segurado.Id;
                //db.Condutor.Add(proposta.OutroCondutor);
            }

            //Adicionando Proposta
            //proposta.codigoSegurado = proposta.Segurado.Id;
            int novoIdProposta = db.Proposta.Add(proposta).Id;

            db.SaveChanges();

            ////correção provisoria
            //if(proposta.CodigoCobertura == 0)
            //{
            //    proposta.CodigoCobertura = 1;
            //}
            //db.SaveChanges();
            db.Dispose();
            return novoIdProposta;
        }
Пример #6
0
        public Proposta GetProposta(int? id)
        {
            Proposta proposta = db.Proposta.Find(id);
            proposta.Cobertura = db.Cobertura.Find(proposta.CodigoCobertura);
            proposta.Segurado = db.Condutor.Find(proposta.codigoSegurado);

            //obtendo telefone
            TelefoneDAO telefoneDao = new TelefoneDAO();
            proposta.Segurado.Telefones = telefoneDao.ObterTodosPorIdCondutor(proposta.Segurado.Id);

            CondutorDAO condutorDao = new CondutorDAO();

            if (proposta.Segurado.IEProprietarioVeiculo == Enumerations.IEProprietarioVeiculo.NAO)
            {
                proposta.Proprietario = condutorDao.ObterPorIdSeguradoETipo(proposta.Segurado.Id, 1);
            }
            if (proposta.Segurado.IECondutorPrincipal == Enumerations.IECondutorPrincipal.OUTRAPESSOA)
            {
                proposta.OutroCondutor = condutorDao.ObterPorIdSeguradoETipo(proposta.Segurado.Id, 2);
            }

            return proposta;
        }