Ejemplo n.º 1
0
        public async Task <Resultado> Cadastrar(FamiliaDto familiaDto)
        {
            var status = await _familiaRepository.ObterStatus(familiaDto.StatusId);

            var familia = _familiaFactory.Criar(status);

            foreach (var pessoa in familiaDto.Pessoas)
            {
                familia.CriarPessoa(
                    Nome.CriarNovo(pessoa.Nome),
                    Idade.CriarNovo(pessoa.DataDeNascimento),
                    pessoa.Tipo,
                    pessoa.Renda.HasValue ? Renda.CriarNovo(pessoa.Renda.Value) : null);
            }
            if (!familia.Validar())
            {
                return(Resultado.Erro("Familia deve possuir apenas um pretendente e apenas um cônjuge."));
            }

            await _familiaRepository.Adicionar(familia);

            if (familia.Status.CadastroValido)
            {
                await _calculoDePontosDosCriteriosAtendidos.Executar(familia);
            }

            return(Resultado.OK());
        }
        public void Configure(EntityTypeBuilder <Pessoa> builder)
        {
            builder.ToTable("Pessoas");

            builder.Property(p => p.Id)
            .HasConversion(
                v => v.ToGuid(),
                v => new PessoaId(v))
            .IsRequired();

            builder.Property(p => p.Nome)
            .HasConversion(
                v => v.ToString(),
                v => Nome.CriarNovo(v))
            .IsRequired();

            builder.Property(p => p.Idade)
            .HasColumnName("DataDeNascimento")
            .HasConversion(
                v => v.DataDeNascimento,
                v => Idade.CriarNovo(v))
            .IsRequired();

            builder.Property(p => p.Renda)
            .HasConversion(
                v => v.Valor.ToDecimal(),
                v => Renda.CriarNovo(v))
            .IsRequired(false);

            builder.Property(p => p.Tipo);

            builder.HasOne(p => p.Familia)
            .WithMany(p => p.Pessoas)
            .HasForeignKey(p => p.FamiliaId);
        }
Ejemplo n.º 3
0
        public static void Main(string[] args)
        {
            double Info;

            Casa Metro = new Casa(Calculos.AreaDaCasa);

            try{
                Info = Metro(16.28, 25.55);
                Console.WriteLine("\n                                 CASA\n\n- A casa tem uma área de {0} m².\n", Info.ToString("F"));
            }
            catch (Exception a) {
                Console.WriteLine("\n\n{0}\n", a.Message);
            }
            finally{
                Console.WriteLine("\n=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-\n");
            }

            Terreno Campo = new Terreno(Calculos.AreaDoTerreno);

            try{
                Info = Campo(105.06, 67.96);
                Console.WriteLine("\n                                TERRENO\n\n- O terreno tem uma área de {0} m².\n", Info.ToString("F"));
            }
            catch (Exception a) {
                Console.WriteLine("\n\n{0}\n", a.Message);
            }
            finally{
                Console.WriteLine("\n-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_\n");
            }

            Idade Usuario = new Idade(Calculos.IdadeDoUsuario);

            try{
                Info = Usuario(DateTime.Now.Year, 2002);
                Console.WriteLine("\n                            IDADE DO USUÁRIO\n\n- O usuário tem {0} anos, atualmente.\n", Info);
            }
            catch (Exception a) {
                Console.WriteLine("\n\n{0}\n", a.Message);
            }
            finally{
                Console.WriteLine("\n-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\n");
            }

            MU S = new MU(Calculos.Space);

            try{
                Info = S(196.1f, 16.8f, 64);
                Console.WriteLine("\n                        MOVIMENTO UNIFORME(M.U.)\n\n- A posição final do veículo é {0} m.\n", Info.ToString("F"));
            }
            catch (Exception a) {
                Console.WriteLine("\n\n{0}\n", a.Message);
            }
            finally{
                Console.WriteLine("\n*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_\n");
            }

            Calculos Hr = new Calculos();

            Hr.Msg();
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Gets the hash code
 /// </summary>
 /// <returns>Hash code</returns>
 public override int GetHashCode()
 {
     unchecked // Overflow is fine, just wrap
     {
         var hashCode = 41;
         // Suitable nullity checks etc, of course :)
         if (Id != null)
         {
             hashCode = hashCode * 59 + Id.GetHashCode();
         }
         if (Nome != null)
         {
             hashCode = hashCode * 59 + Nome.GetHashCode();
         }
         if (Idade != null)
         {
             hashCode = hashCode * 59 + Idade.GetHashCode();
         }
         if (CadastradoEm != null)
         {
             hashCode = hashCode * 59 + CadastradoEm.GetHashCode();
         }
         if (Cpf != null)
         {
             hashCode = hashCode * 59 + Cpf.GetHashCode();
         }
         if (Endereco != null)
         {
             hashCode = hashCode * 59 + Endereco.GetHashCode();
         }
         return(hashCode);
     }
 }
Ejemplo n.º 5
0
 public Segurado(Name nome, Documento documento, Idade idade)
 {
     Nome      = nome;
     Documento = documento;
     Idade     = idade;
     AddNotifications(nome, documento, idade);
 }
Ejemplo n.º 6
0
        public void DeveRetornarExceptionQuandoDataDeNascimentoForNoFuturo()
        {
            var exception = Record.Exception(() => Idade.CriarNovo(DateTime.Today.AddDays(1)));

            Assert.NotNull(exception);
            Assert.IsType <DataDeNascimentoNaoPodeSerNoFuturo>(exception);
        }
Ejemplo n.º 7
0
        private Familia CriarCenarioComDependentesMenoresDeIdade()
        {
            var familiaComDoisDependentesMenoresDeIdade = FamiliaFactory.Criar(
                Status);

            FamiliaFactory.CriarPessoa(
                familiaComDoisDependentesMenoresDeIdade,
                Nome.CriarNovo("Pretendente"),
                Idade.CriarNovo(new DateTime(1997, 10, 25)),
                Tipo.Pretendente,
                Renda.CriarNovo(1000));

            FamiliaFactory.CriarPessoa(
                familiaComDoisDependentesMenoresDeIdade,
                Nome.CriarNovo("Conjugue"),
                Idade.CriarNovo(new DateTime(1997, 01, 01)),
                Tipo.Conjuge,
                Renda.CriarNovo(500));

            FamiliaFactory.CriarPessoa(
                familiaComDoisDependentesMenoresDeIdade,
                Nome.CriarNovo("Dependente 1"),
                Idade.CriarNovo(new DateTime(2010, 01, 01)),
                Tipo.Dependente);

            FamiliaFactory.CriarPessoa(
                familiaComDoisDependentesMenoresDeIdade,
                Nome.CriarNovo("Dependente 2"),
                Idade.CriarNovo(new DateTime(2010, 01, 01)),
                Tipo.Dependente);

            return(familiaComDoisDependentesMenoresDeIdade);
        }
Ejemplo n.º 8
0
        public void DeveRetornarSucessoQuandoPessoaForMaiorDe18Anos()
        {
            var idade  = new Idade(DateTime.Now.AddYears(-18));
            var pessoa = new Pessoa(_idFamilia, _nome, ETipoType.Pretendente, idade, _renda);

            Assert.IsFalse(pessoa.EhMenorDe18Anos());
        }
Ejemplo n.º 9
0
        public Pessoa CriarPessoa(Nome nome, Idade idade, Tipo tipo, Renda renda = null)
        {
            var pessoa = new Pessoa(this.Id, nome, idade, tipo, renda);

            this.Pessoas.Add(pessoa);
            return(pessoa);
        }
Ejemplo n.º 10
0
        public void DeveRetornarExceptionQuandoDataDeNascimentoInforamadaForMinima()
        {
            var exception = Record.Exception(() => Idade.CriarNovo(DateTime.MinValue));

            Assert.NotNull(exception);
            Assert.IsType <DataDeNascimentoNaoPodeTerValorMinimoException>(exception);
        }
Ejemplo n.º 11
0
        public Usuario(string nome, int idade, string email)
        {
            Nome  = new Nome(nome);
            Idade = new Idade(idade);
            Email = new Email(email);

            AddNotifications(Nome, Idade, Email);
        }
Ejemplo n.º 12
0
        public void DeveRetornarIdade(int anoDeNascimento, int mes, int dia, int idadeEsperada)
        {
            var idadeVO = Idade.CriarNovo(new DateTime(anoDeNascimento, mes, dia));

            var idadeCalculada = idadeVO.Obter();

            Assert.Equal(idadeEsperada, idadeCalculada);
        }
Ejemplo n.º 13
0
 public FamiliaTests()
 {
     _status  = new Status(new StatusId(1), new Descricao("Já possui uma casa"), false);
     _familia = new Familia(_status);
     _nome    = new NomeCompleto("Wellington");
     _idade   = new Idade(DateTime.Now.AddYears(-28));
     _renda   = new Renda(0);
     _familia.AdicionarPessoa(_nome, ETipoType.Dependente, _idade, _renda);
 }
Ejemplo n.º 14
0
        public void AdicionarPessoa(NomeCompleto nome, ETipoType tipo, Idade idade, Renda renda)
        {
            var pessoa = new Pessoa(Id, nome, tipo, idade, renda);

            if (pessoa.Invalid)
            {
                AddNotifications(pessoa);
            }
            _pessoas.Add(pessoa);
        }
Ejemplo n.º 15
0
        public Pessoa(EntityId familiaId, NomeCompleto nome, ETipoType tipo, Idade idade, Renda renda)
        {
            FamiliaId = familiaId;
            Id        = new EntityId(Guid.NewGuid());
            Nome      = nome;
            Tipo      = tipo;
            Idade     = idade;
            Renda     = renda;

            AddNotifications(nome, idade, renda);
        }
Ejemplo n.º 16
0
        public bool AtribuirIdade(DateTime dataNascimento)
        {
            var idade = new Idade(dataNascimento);

            if (!idade.EhValido())
            {
                return(false);
            }

            this.Idade = idade;
            return(true);
        }
Ejemplo n.º 17
0
        public Hospede(CPF cpf, Idade idade, AgendaTelefonica agenda,
                       Endereco endereco, Email email)
        {
            if (idade.Valor < 18)
            {
                throw new InvalidOperationException();
            }

            Cpf              = cpf;
            Idade            = idade;
            AgendaTelefonica = agenda;
            Endereco         = endereco;
            Email            = email;
        }
Ejemplo n.º 18
0
        public XmlElement ExportarXml(XmlDocument doc)
        {
            var xmlCliente = doc.CreateElement("cliente");

            var xmlNome = doc.CreateElement("nome");

            xmlNome.InnerText = Nome;
            xmlCliente.AppendChild(xmlNome);

            var xmlIdade = doc.CreateElement("idade");

            xmlIdade.InnerText = Idade.ToString();
            xmlCliente.AppendChild(xmlIdade);

            return(xmlCliente);
        }
    public XmlElement ExportarXml(XmlDocument doc)
    {
      var xmlCliente = doc.CreateElement("animal");

      var xmlNome = doc.CreateElement("nome");
      xmlNome.InnerText = Nome;
      xmlCliente.AppendChild(xmlNome);

      var xmlIdade = doc.CreateElement("Idade");
      xmlIdade.InnerText = Idade.ToString();
      xmlCliente.AppendChild(xmlIdade);

      var xmlSexo = doc.CreateElement("Sexo");
      xmlSexo.InnerText = Sexo.ToString();
      xmlCliente.AppendChild(xmlSexo);

      return xmlCliente;
    }
Ejemplo n.º 20
0
        public String RetornarStringCliente()
        {
            String        separador      = "|";
            String        separadorFinal = "#";
            StringBuilder stringBuilder  = new StringBuilder();

            stringBuilder.AppendLine(" " + TipoCliente.ToString() + separador);
            stringBuilder.AppendLine(" " + CodigoDoCliente.ToString() + separador);
            stringBuilder.AppendLine(" " + Nome + separador);
            stringBuilder.AppendLine(" " + Idade.ToString() + separador);
            stringBuilder.AppendLine(" " + EstadoCivil.ToString() + separador);
            stringBuilder.AppendLine(" " + Genero.ToString() + separador);
            stringBuilder.Append(" " + separadorFinal);

            String descricao = stringBuilder.ToString();

            return(descricao);
        }
Ejemplo n.º 21
0
        public override string ToString()
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("Nome:" + Nome);
            sb.Append(",Idade:" + Idade.ToString());
            sb.Append(",Esportes:");

            if (Esportes != null)
            {
                foreach (var item in Esportes)
                {
                    sb.Append(item);
                }
            }

            return(sb.ToString());
        }
Ejemplo n.º 22
0
        /// <summary>
        /// Returns true if Cliente instances are equal
        /// </summary>
        /// <param name="other">Instance of Cliente to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(Cliente other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     Id == other.Id ||
                     Id != null &&
                     Id.Equals(other.Id)
                     ) &&
                 (
                     Nome == other.Nome ||
                     Nome != null &&
                     Nome.Equals(other.Nome)
                 ) &&
                 (
                     Idade == other.Idade ||
                     Idade != null &&
                     Idade.Equals(other.Idade)
                 ) &&
                 (
                     CadastradoEm == other.CadastradoEm ||
                     CadastradoEm != null &&
                     CadastradoEm.Equals(other.CadastradoEm)
                 ) &&
                 (
                     Cpf == other.Cpf ||
                     Cpf != null &&
                     Cpf.Equals(other.Cpf)
                 ) &&
                 (
                     Endereco == other.Endereco ||
                     Endereco != null &&
                     Endereco.Equals(other.Endereco)
                 ));
        }
Ejemplo n.º 23
0
        public XmlElement ExportarXml(XmlDocument doc)
        {
            var xmlCliente = doc.CreateElement("cliente");

            var xmlCpf = doc.CreateElement("cpf");

            xmlCpf.InnerText = Cpf;
            xmlCliente.AppendChild(xmlCpf);

            var xmlNome = doc.CreateElement("nome");

            xmlNome.InnerText = Nome;
            xmlCliente.AppendChild(xmlNome);

            var xmlIdade = doc.CreateElement("Idade");

            xmlIdade.InnerText = Idade.ToString();
            xmlCliente.AppendChild(xmlIdade);

            var xmlSexo = doc.CreateElement("Sexo");

            xmlSexo.InnerText = Sexo == EnumSexo.Masculino ? "Masculino" : "Feminino";
            xmlCliente.AppendChild(xmlSexo);

            var xmlCarteiraMotorista = doc.CreateElement("CarteiraMotorista");

            xmlCarteiraMotorista.InnerText = CarteiraMotorista.ToString();
            xmlCliente.AppendChild(xmlCarteiraMotorista);

            var xmlCarteiraReservista = doc.CreateElement("CarteiraReservista");

            xmlCarteiraReservista.InnerText = CarteiraReservista.ToString();
            xmlCliente.AppendChild(xmlCarteiraReservista);

            if (Endereco != null)
            {
                xmlCliente.AppendChild(Endereco.ExportarXml(doc));
            }

            return(xmlCliente);
        }
Ejemplo n.º 24
0
 public CriterioDaIdadeDoPretendenteDe30A44Anos(Idade idade) : base(idade, idade => idade.Obter() >= 30 && idade.Obter() <= 44)
 {
 }
Ejemplo n.º 25
0
 public CriterioDaIdadeDoPretendenteAbaixoDos30Anos(Idade idade) : base(idade, idade => idade.Obter() < 30)
 {
 }
Ejemplo n.º 26
0
        public void DeveRetornarErrorQuandoDataMaiorQueDataAtual()
        {
            var idade = new Idade(DateTime.Now.AddDays(2));

            Assert.IsTrue(idade.Invalid);
        }
Ejemplo n.º 27
0
 public int ObterIdade()
 {
     return(Idade.ObterIdade());
 }
Ejemplo n.º 28
0
 public bool EhMenorDe18Anos()
 {
     return(Idade.ObterIdade() < 18);
 }
Ejemplo n.º 29
0
        public void DeveRetornarErrorQuandoDataForIgualAMinDate()
        {
            var idade = new Idade(DateTime.MinValue);

            Assert.IsTrue(idade.Invalid);
        }
Ejemplo n.º 30
0
        public void DeveRetornarSucessoQuandoDataForValida()
        {
            var idade = new Idade(DateTime.Now.AddYears(-10));

            Assert.IsTrue(idade.Valid);
        }