Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            //INTERFACE

            decimal consumption = 500;

            SocioFactory.type = SocioType.Aviador;
            ISocio AvSocio = SocioFactory.Create();

            AvSocio.wilstermanista = "Juan";
            AvSocio.maxConsumption = 1500;
            PayBeingSocio(AvSocio, consumption);
            Console.WriteLine($"-------------");
            Action <ISocio, decimal> payAction = PayBeingSocio; //delegate

            consumption       = 1500;
            SocioFactory.type = SocioType.HerculesAviador;
            ISocio HercAvSocio = SocioFactory.Create();

            HercAvSocio.wilstermanista = "Juslan";
            HercAvSocio.maxConsumption = 3000;
            payAction(HercAvSocio, consumption);


            //LINQ
            //Console.WriteLine($"LINQ");
            //FirstHomework.Linq.Tester.Test();

            //GENERICS (QUEUE)
            //Console.WriteLine($"QUEUE");
            //FirstHomework.Generics.Tester.Test();
        }
Ejemplo n.º 2
0
        public SocioDTO AddSocio(SocioDTO socioDTO)
        {
            try
            {
                if (socioDTO == null)
                {
                    throw new ArgumentNullException("socioDTO");
                }

                if (socioDTO.Cpf != null)
                {
                    socioDTO.Cpf = socioDTO.Cpf.Replace("-", "").Replace(".", "").Replace("_", "").Trim();
                }
                if (socioDTO.Telefone != null)
                {
                    socioDTO.Telefone = socioDTO.Telefone.Replace("_", "").Replace("-", "").Trim();
                }
                if (socioDTO.Celular != null)
                {
                    socioDTO.Celular = socioDTO.Celular.Replace("_", "").Replace("-", "").Trim();
                }

                var Socio = SocioFactory.CreateSocio(
                    socioDTO.Nome,
                    socioDTO.Administrador,
                    socioDTO.DataNascimento,
                    socioDTO.Rg,
                    socioDTO.OrgaoRG,
                    socioDTO.Cpf,
                    socioDTO.NomeMae,
                    socioDTO.NomePai,
                    socioDTO.Cnh,
                    socioDTO.Nacionalidade,
                    socioDTO.Naturalidade,
                    socioDTO.Sexo,
                    socioDTO.EstadoCivil,
                    socioDTO.Telefone,
                    socioDTO.Celular,
                    socioDTO.Email,
                    socioDTO.Participacao,
                    socioDTO.Assina,
                    socioDTO.Rua,
                    socioDTO.Numero,
                    socioDTO.Complemento,
                    socioDTO.Bairro,
                    socioDTO.Cidade,
                    socioDTO.Cep,
                    socioDTO.Referencia,
                    socioDTO.Estado,
                    socioDTO.EntrevistaId

                    );

                SalvarSocio(Socio);

                var adapter = TypeAdapterFactory.CreateAdapter();
                return(adapter.Adapt <Socio, SocioDTO>(Socio));
            }
            catch (Exception ex)
            {
                throw ManipuladorDeExcecao.TrateExcecao(ex);
            }
        }
Ejemplo n.º 3
0
        public SocioDTO UpdateSocio(SocioDTO socioDTO)
        {
            try
            {
                if (socioDTO == null)
                {
                    throw new ArgumentNullException("SocioDTO");
                }

                if (socioDTO.Cpf != null)
                {
                    socioDTO.Cpf = socioDTO.Cpf.Replace("-", "").Replace(".", "").Replace("_", "").Trim();
                }
                if (socioDTO.Telefone != null)
                {
                    socioDTO.Telefone = socioDTO.Telefone.Replace("_", "").Replace("-", "").Trim();
                }
                if (socioDTO.Celular != null)
                {
                    socioDTO.Celular = socioDTO.Celular.Replace("_", "").Replace("-", "").Trim();
                }

                var persistido = _socioRepository.Get(socioDTO.Id);
                if (persistido == null)
                {
                    throw new Exception("Sócio não encontrado.");
                }

                var corrente = SocioFactory.CreateSocio(
                    socioDTO.Nome,
                    socioDTO.Administrador,
                    socioDTO.DataNascimento,
                    socioDTO.Rg,
                    socioDTO.OrgaoRG,
                    socioDTO.Cpf,
                    socioDTO.NomeMae,
                    socioDTO.NomePai,
                    socioDTO.Cnh,
                    socioDTO.Nacionalidade,
                    socioDTO.Naturalidade,
                    socioDTO.Sexo,
                    socioDTO.EstadoCivil,
                    socioDTO.Telefone,
                    socioDTO.Celular,
                    socioDTO.Email,
                    socioDTO.Participacao,
                    socioDTO.Assina,
                    socioDTO.Rua,
                    socioDTO.Numero,
                    socioDTO.Complemento,
                    socioDTO.Bairro,
                    socioDTO.Cidade,
                    socioDTO.Cep,
                    socioDTO.Referencia,
                    socioDTO.Estado,
                    persistido.EntrevistaId
                    );

                corrente.Id = persistido.Id;

                AlterarSocio(persistido, corrente);

                var adapter = TypeAdapterFactory.CreateAdapter();
                return(adapter.Adapt <Socio, SocioDTO>(corrente));
            }
            catch (Exception ex)
            {
                throw ManipuladorDeExcecao.TrateExcecao(ex);
            }
        }