Пример #1
0
        public void Adicionar(Seguradora seguradora)
        {
            db.Seguradoras.Add(seguradora);

            // n entendi mto bem.
            foreach (var acrescimoTipoViagem in seguradora.AcrescimosViagens)
            {
                acrescimoTipoViagem.SegId = seguradora.SegId;
                db.AcrescimosTipoViagem.Add(acrescimoTipoViagem);
            }

            foreach (var acrescimoMeioTransporte in seguradora.AcrescimosTransportes)
            {
                acrescimoMeioTransporte.SegId = seguradora.SegId;
                db.AcrescimosMeioTransporte.Add(acrescimoMeioTransporte);
            }

            foreach (var acrescimoMotivoViagem in seguradora.AcrescimosMotivos)
            {
                acrescimoMotivoViagem.SegId = seguradora.SegId;
                db.AcrescimosMotivoViagem.Add(acrescimoMotivoViagem);
            }

            db.SaveChanges();
        }
Пример #2
0
        public ActionResult Remover(Seguradora seguradoras)
        {
            var dao = new SeguradoraDAO();

            dao.Remover(seguradoras);
            return(RedirectToAction("Listar"));
        }
Пример #3
0
        public ActionResult Remover(int id)
        {
            var        dao         = new SeguradoraDAO();
            Seguradora seguradoras = dao.BuscarPorId(id);

            return(View(seguradoras));
        }
Пример #4
0
        public void Save(Seguradora info)
        {
            using (var context = new Context())
            {
                var seguradora = context.Seguradoras.Find(info.Id);

                seguradora.Bairro            = info.Bairro;
                seguradora.CEP               = info.CEP;
                seguradora.Cidade            = info.Cidade;
                seguradora.Complemento       = info.Complemento;
                seguradora.Contatos          = info.Contatos;
                seguradora.Email             = info.Email;
                seguradora.Endereco          = info.Endereco;
                seguradora.Nome              = info.Nome;
                seguradora.Numero            = info.Numero;
                seguradora.Site              = info.Site;
                seguradora.Telefone1         = info.Telefone1;
                seguradora.Telefone2         = info.Telefone2;
                seguradora.Celular1          = info.Celular1;
                seguradora.Celular2          = info.Celular2;
                seguradora.Celular1Operadora = info.Celular1Operadora;
                seguradora.Celular2Operadora = info.Celular2Operadora;
                seguradora.UF = info.UF;

                context.SaveChanges();
            }
        }
Пример #5
0
        public void CalculaValorSeguradora(Seguradora seguradora, Cotacao cotacao)
        {
            var acrescimoTipoViagem = new AcrescimoTipoViagemDAO().ObterPorTipoViagem(seguradora.SegId, cotacao.TipoViagem); // passando como parâmetro os valores da tabela seguradora.SegId e tabela cotacao.TipoViagem

            double acrescimo1 = 0, acrescimo2 = 0, acrescimo3 = 0;

            var ValorDias   = seguradora.ValorPorDia * cotacao.QtdeDias;         // Valor por dia * qntide de dias que o usuário vai ficar
            var ValorPessoa = seguradora.ValorPorPessoa * cotacao.QtdeViajantes; // Valor por pessoa * qntde de Viajantes
            var Comissao    = (seguradora.Comissao / 100) + 1;
            var ValorFinal  = ValorDias + ValorPessoa;

            if (acrescimoTipoViagem != null)
            {
                acrescimo1 = ValorFinal * ((acrescimoTipoViagem.AcrescimoViagem / 100) + 1);  //
            }


            var acrescimoMeioTransporte = new AcrescimoMeioTransporteDAO().ObterPorMeioTransporte(seguradora.SegId, cotacao.MeioTransporte);

            if (acrescimoMeioTransporte != null)
            {
                acrescimo2 = ValorFinal * ((acrescimoMeioTransporte.AcrescimoTransporte / 100) + 1);
            }

            var acrescimoMotivoViagem = new AcrescimoMotivoViagemDAO().OberPorMotivoViagem(seguradora.SegId, cotacao.MotivoViagem);

            if (acrescimoMotivoViagem != null)
            {
                acrescimo3 = ValorFinal * ((acrescimoMotivoViagem.AcrescimoMotivo / 100) + 1);
            }

            seguradora.Valor  = (acrescimo1 + acrescimo2 + acrescimo3) * Comissao;
            seguradora.CotdId = cotacao.CotId;
        }
Пример #6
0
        public ActionResult Inserir()
        {
            // Inicializo as listas que criei no model
            var model = new Seguradora().inicializar();

            return(View(model));
        }
Пример #7
0
        public async Task <IActionResult> Edit(int id, [Bind("ID,CNPJ,Email,Endereco,Nome,Telefone")] Seguradora seguradora)
        {
            if (id != seguradora.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(seguradora);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!SeguradoraExists(seguradora.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Index"));
            }
            return(View(seguradora));
        }
Пример #8
0
        private void btnAdicionar_Click(object sender, EventArgs e)
        {
            Seguradora segurad = new Seguradora
            {
                Nome              = txtNome.Text,
                Endereco          = txtEndereco.Text,
                Complemento       = txtComplemento.Text,
                Numero            = txtNumero.Text,
                CEP               = txtCEP.Text,
                Bairro            = txtBairro.Text,
                Cidade            = txtCidade.Text,
                UF                = cmbUf.Text,
                Site              = txtSite.Text,
                Email             = txtEmail.Text,
                Telefone1         = txtFone1.Text,
                Telefone2         = txtFone2.Text,
                Celular1          = txtCelular1.Text,
                Celular2          = txtCelular2.Text,
                Celular1Operadora = cmbOperadora1.Text,
                Celular2Operadora = cmbOperadora2.Text,
                Contatos          = txtContatos.Text
            };

            try
            {
                seguradoraBLL.Insert(segurad);
                this.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show($"Falha ao salvar dados: {ex.Message}", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Пример #9
0
        public ActionResult DeleteConfirmed(int id)
        {
            Seguradora seguradora = db.Seguradora.Find(id);

            db.Seguradora.Remove(seguradora);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Пример #10
0
 public void Insert(Seguradora info)
 {
     using (var context = new Context())
     {
         context.Seguradoras.Add(info);
         context.SaveChanges();
     }
 }
Пример #11
0
 public ActionResult Edit([Bind(Include = "Id,NomeSeguradora")] Seguradora seguradora)
 {
     if (ModelState.IsValid)
     {
         db.Entry(seguradora).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(seguradora));
 }
Пример #12
0
        public ActionResult Create([Bind(Include = "Id,NomeSeguradora")] Seguradora seguradora)
        {
            if (ModelState.IsValid)
            {
                db.Seguradora.Add(seguradora);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(seguradora));
        }
Пример #13
0
        public async Task <IActionResult> Create([Bind("ID,CNPJ,Email,Endereco,Nome,Telefone")] Seguradora seguradora)
        {
            if (ModelState.IsValid)
            {
                _context.Add(seguradora);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(seguradora));
        }
Пример #14
0
 public frmSeguradora(int Id)
 {
     InitializeComponent();
     btnAdicionar.Visible = false;
     btnEditar.Visible    = true;
     seguradora           = seguradoraBLL.Get(Id);
     PreencherFormulario();
     DesabilitarCampos();
     btnEditar.Location = new Point(595, 417);
     btnSalvar.Visible  = false;
 }
        /// <summary>
        /// Inicia uma nova instância da classe <see cref="ConverterCadastroAtualizacaoParaSeguradora"/>.
        /// </summary>
        /// <param name="cadastro">O DTO de cadastro, enviado para o endpoint.</param>
        /// <param name="atual">A seguradora atual (opcional), para que sejam aproveitados os valores, se necessário.</param>
        public ConverterCadastroAtualizacaoParaSeguradora(
            CadastroAtualizacaoDto cadastro,
            Seguradora atual = null)
        {
            this.cadastro   = cadastro;
            this.seguradora = new Lazy <Seguradora>(() =>
            {
                var destino = atual ?? new Seguradora();
                this.ConverterDtoParaModelo(destino);

                return(destino);
            });
        }
Пример #16
0
 public ActionResult Atualizar(Seguradora seguradoras)
 {
     if (ModelState.IsValid)
     {
         var dao = new SeguradoraDAO();
         dao.Atualizar(seguradoras);
         return(RedirectToAction("Listar"));
     }
     else
     {
         return(View("Atualizar"));
     }
 }
Пример #17
0
        // GET: Seguradora/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Seguradora seguradora = db.Seguradora.Find(id);

            if (seguradora == null)
            {
                return(HttpNotFound());
            }
            return(View(seguradora));
        }
Пример #18
0
        public void Remover(Seguradora seguradoraRemover)
        {
            var seguradora = db.Seguradoras.Include(c => c.AcrescimosMotivos).Include(c => c.AcrescimosTransportes).Include(c => c.AcrescimosViagens).Where(f => f.SegId == seguradoraRemover.SegId).FirstOrDefault();

            foreach (var acrescimoViagem in seguradora.AcrescimosViagens.ToList())
            {
                db.AcrescimosTipoViagem.Remove(acrescimoViagem);
            }
            foreach (var acrescimoMotivo in seguradora.AcrescimosMotivos)
            {
                db.AcrescimosMotivoViagem.Remove(acrescimoMotivo);
            }
            foreach (var acrescimosTransporte in seguradora.AcrescimosTransportes)
            {
                db.AcrescimosMeioTransporte.Remove(acrescimosTransporte);
            }
            db.Seguradoras.Remove(seguradora);
            db.SaveChanges();
        }
Пример #19
0
        public IActionResult Incluir([FromBody] Seguradora salvado)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }


            try
            {
                _app.Incluir(salvado);
                return(Ok());
            }
            catch (Domain.Validations.ExcecaoDeDominio ex)
            {
                return(BadRequest(new { Mensagem = ex.Mensagens }));
            }
            catch (Exception ex)
            {
                return(StatusCode(500, new { Mensagens = ex.Message }));
            }
        }
Пример #20
0
 public void Save(Seguradora info)
 {
     dal.Save(info);
 }
 private void ConverterDtoParaModelo(Seguradora destino)
 {
     destino.NomeSeguradora = this.cadastro.ObterValorNormalizado(c => c.Nome, destino.NomeSeguradora);
     destino.CNPJ           = this.cadastro.ObterValorNormalizado(c => c.Cnpj, destino.CNPJ);
 }
Пример #22
0
 public void Atualizar(Seguradora seguradora)
 {
     db.Seguradoras.Update(seguradora);
     db.SaveChanges();
 }
Пример #23
0
 public void Insert(Seguradora info)
 {
     dal.Insert(info);
 }