Example #1
0
        static void Main(string[] args)
        {
            NotaFiscal notaFiscalDataAtual = (new NotaFiscalBuilder())
                                             .ParaEmpresa("Teste com data atual")
                                             .ComCNPJ("2992929292")
                                             .ComItem(new ItemDaNota("prod1", 100))
                                             .ComObservacoes("observacao")
                                             .AdicionaAcao(new NotaFiscalDAO())
                                             .AdicionaAcao(new EnviaEmail())
                                             .AdicionaAcao(new Multiplicador(2))
                                             .Constroi();

            Show(notaFiscalDataAtual);

            NotaFiscal notaFiscalDataEspecifica = (new NotaFiscalBuilder())
                                                  .ParaEmpresa("Teste com data especifica")
                                                  .ComCNPJ("2992929292")
                                                  .ComItem(new ItemDaNota("prod1", 300))
                                                  .ComObservacoes("observacao")
                                                  .ComDataEmissaoEspecifica(new DateTime(1978, 5, 3))
                                                  .Constroi();

            Show(notaFiscalDataEspecifica);
        }
Example #2
0
        private static void Builder()
        {
            ItemDaNotaBuilder itemBuilder = new ItemDaNotaBuilder();

            itemBuilder
            .ComNome("item1")
            .ComValor(100);
            var item1 = itemBuilder.Constroi();

            itemBuilder
            .ComNome("item2")
            .ComValor(200);
            var item2 = itemBuilder.Constroi();

            itemBuilder
            .ComNome("item3")
            .ComValor(200);
            var item3 = itemBuilder.Constroi();


            NotaFiscalBuilder builder = new NotaFiscalBuilder();

            builder
            .ComRazaoSocial("Filomeno Advogados")
            .ComCnpj("24.093.094/0001.59")
            .Com(item1)
            .Com(item2)
            .Com(item3)
            .ComObservacoes("uma observacao qualquer");

            NotaFiscal nota = builder.Constroi();

            nota.Imprime();

            Console.ReadKey();
        }
Example #3
0
        static void Main(string[] args)
        {
            Console.WriteLine("Builder");
            Console.WriteLine("");


            NotaFiscalBuilder builder = new NotaFiscalBuilder()
                                        .ParaEmpresa("123.456.789/0001-10", "N2S Software Ltda")
                                        .ParaDataAtual()
                                        .ComItem(new ItemDaNota("Notebook", 3500.0))
                                        .ComItem(new ItemDaNota("Impressora", 1000.0))
                                        .ComObservacoes("Nota de teste do design pattern builder");


            NotaFiscal notaFiscal = builder.Build();

            Console.WriteLine($"Cnpj: {notaFiscal.Cnpj}");
            Console.WriteLine($"Razao Social: {notaFiscal.RazaoSocial}");
            Console.WriteLine($"Valor Bruto: {notaFiscal.ValorBruto}");
            Console.WriteLine($"Impostos: {notaFiscal.Impostos}");
            Console.WriteLine($"Observacoes: {notaFiscal.Observacoes}");

            Console.ReadKey();
        }
Example #4
0
 public void Executa(NotaFiscal notaFiscal)
 {
     Console.WriteLine("Valor Bruto ({2}) multiplicado por {0} é igual a {1}", this.Fator, notaFiscal.ValorBruto * this.Fator, notaFiscal.ValorBruto);
 }
Example #5
0
 public void Executa(NotaFiscal notaFiscal)
 {
     Console.WriteLine("Salvando nota fiscal de {0}", notaFiscal.RazaoSocial);
 }
Example #6
0
 void IAcaoNotaPosGeracao.Executa(NotaFiscal notaFiscal)
 {
     Console.WriteLine("Enviando nota fiscal para {0}", notaFiscal.RazaoSocial);
 }
Example #7
0
 public void Executa(NotaFiscal notaFiscal)
 {
     Console.WriteLine("Persistir NF no banco de dados");
 }
Example #8
0
 public void Executa(NotaFiscal notaFiscal)
 {
     Console.WriteLine($"Valor multiplicado: R$ {(notaFiscal.ValorBruto * Fator):F2}");
 }