Exemple #1
0
        public override double Calcular(Operacao operacao, Corretora corretora)
        {
            double total = operacao.Quantidade * operacao.Cotacao.Valor;

            total += total * 0.000035;
            return(total);
        }
Exemple #2
0
 //Corretora
 public Corretora CorretoraAdicionar(Corretora Corretora)
 {
     //if (!Corretora.IsValid())
     //    return Corretora;
     _CorretoraRepository.Add(Corretora);
     return(Corretora);
 }
        public override double Calcular(Operacao operacao, Corretora corretora)
        {
            double total = operacao.Quantidade*operacao.Cotacao.Valor;
            total += 10;
            total += total*0.03;

            return total;
        }
Exemple #4
0
        public void DeveGravarCorretoraUtilizandoUnityMethodInjection()
        {
            var container = new UnityContainer();

            container.RegisterType <IRepositorio <Corretora>, RepositorioCorretoraFake>();

            Corretora corretora = container.Resolve <Corretora>();

            corretora.Nome = "Corretora Teste";
            Assert.IsTrue(corretora.Gravar());
        }
Exemple #5
0
        public int CompareTo(CorretorasInfo obj)
        {
            int comparaVolumeBruto = VolumeBruto.CompareTo(obj.VolumeBruto);

            if (comparaVolumeBruto != 0)
            {
                return(comparaVolumeBruto);
            }

            return(Corretora.CompareTo(obj.Corretora));
        }
Exemple #6
0
        public async Task <Corretora> PutCorretora(int corretoraId, Corretora corretora)
        {
            if (corretoraId != corretora.CorretoraId)
            {
                return(null);
            }

            await _bCorretora.Update(corretora);

            return(corretora);
        }
        public Corretora Get(
            [FromServices] IConfiguration configuration,
            [FromServices] ILogger <AcoesController> logger)
        {
            var corretora = new Corretora()
            {
                Codigo = configuration["Corretora:Codigo"],
                Nome   = configuration["Corretora:Nome"]
            };

            logger.LogInformation($"Dados: {JsonSerializer.Serialize(corretora)}");

            return(corretora);
        }
Exemple #8
0
        static void Main(string[] args)
        {
            IAcao acao = new Acao("Vale-100", 100);

            var corretora_1 = new Corretora("Corretora 1");
            var corretora_2 = new Corretora("Corretora 2");

            acao.RegistraInteressado(corretora_1);
            acao.RegistraInteressado(corretora_2);

            acao.SetValor(20);


            Console.ReadKey();
        }
        static void Main(string[] args)
        {
            Corretora corretora = new Corretora();

            OrdemDeCompra ordemDeCompra1 = new OrdemDeCompra(corretora);
            OrdemDeCompra ordemDeCompra2 = new OrdemDeCompra(corretora);
            OrdemDeVenda  ordemDeVenda   = new OrdemDeVenda(corretora);

            Corretor corretor = new Corretor();

            corretor.EnviarOrdem(ordemDeCompra1);
            corretor.EnviarOrdem(ordemDeCompra2);
            corretor.EnviarOrdem(ordemDeVenda);


            Console.ReadKey();
        }
        static void Main(string[] args)
        {
            Corretora corretora = new Corretora();

            OrdemDeCompra ordemDeCompra1 = new OrdemDeCompra(corretora);
            OrdemDeCompra ordemDeCompra2 = new OrdemDeCompra(corretora);
            OrdemDeVenda  ordemDeVenda = new OrdemDeVenda(corretora);

            Corretor corretor = new Corretor();
            corretor.EnviarOrdem(ordemDeCompra1);
            corretor.EnviarOrdem(ordemDeCompra2);
            corretor.EnviarOrdem(ordemDeVenda);
            

            Console.ReadKey();

        }
Exemple #11
0
        public static string GenerateToken(Corretora corretora)
        {
            var tokenHandler    = new JwtSecurityTokenHandler();
            var key             = Encoding.ASCII.GetBytes(Settings.Secret);
            var tokenDescriptor = new SecurityTokenDescriptor
            {
                Subject = new ClaimsIdentity(new Claim[]
                {
                    new Claim(ClaimTypes.Name, corretora.Nome.ToString()),
                    new Claim(ClaimTypes.Role, corretora.Role.ToString())
                }),
                Expires            = DateTime.UtcNow.AddHours(2),
                SigningCredentials = new SigningCredentials(new SymmetricSecurityKey(key), SecurityAlgorithms.HmacSha256Signature)
            };
            var token = tokenHandler.CreateToken(tokenDescriptor);

            return(tokenHandler.WriteToken(token));
        }
        public async Task <ActionResult <Corretora> > Post([FromServices] DataContext context,
                                                           [FromBody] Corretora model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            try
            {
                model.Role = "funcionario";
                context.Corretora.Add(model);
                await context.SaveChangesAsync();

                model.Password = "";
                return(model);
            }
            catch (Exception e)
            {
                return(BadRequest(new { message = "Não foi possível criar o usuário: " + e.Message }));
            }
        }
 public virtual double Calcular(Operacao operacao, Corretora corretora)
 {
     return 1;
 }
Exemple #14
0
        public async Task <Corretora> Post(Corretora corretora)
        {
            await _bCorretora.Add(corretora);

            return(corretora);
        }
Exemple #15
0
 public Corretora CorretoraAtualizar(Corretora Corretora)
 {
     return(_CorretoraRepository.Update(Corretora));
 }
        public Repository Delete(Repository value)
        {
            using (db = new PinheiroSereniContext())
            {
                try
                {
                    #region validar exclusão
                    value.mensagem = this.Validate(value, Crud.EXCLUIR);
                    #endregion

                    #region altera a corretora
                    if (value.mensagem.Code == 0)
                    {
                        CorretoraRepository r    = (CorretoraRepository)value;
                        Corretora           corr = db.Corretoras.Find(r.corretora.corretoraId);
                        db.Corretoras.Remove(corr);
                        db.SaveChanges();
                    }
                    else
                    {
                        value.mensagem.MessageBase = MensagemPadrao.Message(999).ToString();
                    }

                    #endregion
                }
                catch (System.Data.Entity.Infrastructure.DbUpdateException ex)
                {
                    value.mensagem.Code        = 36;
                    value.mensagem.MessageBase = MensagemPadrao.Message(36).ToString();
                    if ((ex.Message.ToUpper().Contains("FOREIGN KEY") || ex.Message.ToUpper().Contains("REFERENCE")) ||
                        (ex.InnerException.ToString().ToUpper().Contains("FOREIGN KEY") || ex.InnerException.ToString().ToUpper().Contains("REFERENCE")))
                    {
                        value.mensagem.Code    = 16;
                        value.mensagem.Message = MensagemPadrao.Message(16).ToString();
                    }
                    else if (ex.Message.ToUpper().Contains("PRIMARY KEY") ||
                             ex.InnerException.ToString().ToUpper().Contains("PRIMARY KEY"))
                    {
                        value.mensagem.Code    = 37;
                        value.mensagem.Message = MensagemPadrao.Message(37).ToString();
                    }
                    else
                    {
                        value.mensagem.Message = MensagemPadrao.Message(17).ToString();
                    }
                    PinheiroSereniException.saveError(ex, GetType().FullName);
                }
                catch (ArgumentException ex)
                {
                    value.mensagem = new Validate()
                    {
                        Code = 17, Message = MensagemPadrao.Message(17).ToString(), MessageBase = ex.Message
                    };
                }
                catch (Exception ex)
                {
                    PinheiroSereniException.saveError(ex, GetType().FullName);
                    value.mensagem.Code        = 17;
                    value.mensagem.MessageBase = ex.InnerException.InnerException.Message ?? ex.Message;
                    value.mensagem.Message     = new PinheiroSereniException(ex.Message, GetType().FullName).Message;
                }
            }

            return(value);
        }
        public async Task <ActionResult <dynamic> > Authenticate([FromServices] DataContext context, [FromBody] Corretora model)
        {
            var user = await context.Corretora
                       .AsNoTracking()
                       .Where(x => x.Nome == model.Nome && x.Password == model.Password)
                       .FirstOrDefaultAsync();

            if (user == null)
            {
                return(NotFound(new { message = "Usuário ou senha inválidos" }));
            }

            var token = TokenService.GenerateToken(user);

            user.Password = "";
            return(new
            {
                user = user,
                token = token
            });
        }
Exemple #18
0
        public void Seed()
        {
            if (_context.Contato.Any() || _context.Telefone.Any() || _context.Corretora.Any())
            {
                return;
            }
            else
            {
                Telefone t1 = new Telefone()
                {
                    Numero = "(012)98888-7777"
                };
                Telefone t2 = new Telefone()
                {
                    Numero = "(012)96666-5555"
                };
                Telefone t3 = new Telefone()
                {
                    Numero = "(012)91111-8888"
                };
                Telefone t4 = new Telefone()
                {
                    Numero = "(012)92222-6666"
                };
                Telefone t5 = new Telefone()
                {
                    Numero = "(012)93333-5555"
                };
                Telefone t6 = new Telefone()
                {
                    Numero = "(012)94444-4444"
                };
                Telefone t7 = new Telefone()
                {
                    Numero = "(012)95555-3333"
                };
                Telefone t8 = new Telefone()
                {
                    Numero = "(012)96666-2222"
                };
                Telefone t9 = new Telefone()
                {
                    Numero = "(012)97777-1111"
                };
                Telefone t10 = new Telefone()
                {
                    Numero = "(012)98888-9999"
                };
                Telefone t11 = new Telefone()
                {
                    Numero = "(012)90000-1111"
                };
                Telefone t12 = new Telefone()
                {
                    Numero = "(012)97474-0101"
                };

                Contato c1 = new Contato()
                {
                    Nome = "Luiz", Sobrenome = "Roberto", Email = "*****@*****.**", Telefones = new List <Telefone>()
                    {
                        t1, t2
                    }
                };
                Contato c2 = new Contato()
                {
                    Nome = "Maria", Sobrenome = "Santos", Email = "*****@*****.**", Telefones = new List <Telefone>()
                    {
                        t3, t4
                    }
                };
                Contato c3 = new Contato()
                {
                    Nome = "Leonardo", Sobrenome = "Souza", Email = "*****@*****.**", Telefones = new List <Telefone>()
                    {
                        t5, t6
                    }
                };
                Contato c4 = new Contato()
                {
                    Nome = "Pedro", Sobrenome = "Soares", Email = "*****@*****.**", Telefones = new List <Telefone>()
                    {
                        t7, t8
                    }
                };
                Contato c5 = new Contato()
                {
                    Nome = "Roberto", Sobrenome = "Cavalcante", Email = "*****@*****.**", Telefones = new List <Telefone>()
                    {
                        t9, t10
                    }
                };
                Contato c6 = new Contato()
                {
                    Nome = "Rafael", Sobrenome = "Dumon", Email = "*****@*****.**", Telefones = new List <Telefone>()
                    {
                        t11, t12
                    }
                };

                Corretora co1 = new Corretora()
                {
                    Nome = "Porto Seguro", Password = "******", Role = "funcionario", Contatos = new List <Contato> {
                        c1, c2
                    }
                };
                Corretora co2 = new Corretora()
                {
                    Nome = "Caixa Seguros", Password = "******", Role = "gerente", Contatos = new List <Contato> {
                        c3, c4
                    }
                };
                Corretora co3 = new Corretora()
                {
                    Nome = "Quiver Seguro", Password = "******", Role = "diretor", Contatos = new List <Contato> {
                        c5, c6
                    }
                };

                _context.Telefone.AddRange(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12);
                _context.Contato.AddRange(c1, c2, c3, c4, c5, c6);
                _context.Corretora.AddRange(co1, co2, co3);

                _context.SaveChanges();
            }
        }
        public async Task <ActionResult <Corretora> > Put([FromServices] DataContext context, int id, [FromBody] Corretora model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != model.Id)
            {
                return(NotFound(new { message = "Usuário não encontrada" }));
            }

            try
            {
                context.Entry(model).State = EntityState.Modified;
                await context.SaveChangesAsync();

                return(model);
            }
            catch (Exception)
            {
                return(BadRequest(new { message = "Não foi possível criar o usuário" }));
            }
        }
 public virtual double Calcular(Operacao operacao, Corretora corretora)
 {
     return(1);
 }