示例#1
0
        public LegalPersonModel GetById(long id)
        {
            var legalPerson = legalPersonService.GetById(id);
            var model       = new LegalPersonModel(legalPerson);

            return(model);
        }
示例#2
0
        public LegalPersonCoordinator(LegalPersonModel legalPerson)
        {
            // Classe de Crawler base, apenas duplique
            // AddModule(new ExampleCrawler("julio+cesar"));

            AddModule(new ArispCrawler(legalPerson.getTypePerson(), legalPerson.CNPJ));
        }
示例#3
0
        public async Task <IActionResult> Update(Guid id, LegalPersonModel model)
        {
            if (!ModelState.IsValid || id != model.Id)
            {
                return(BadRequest());
            }

            try
            {
                await _repository.UpdateById(id, model);

                return(Ok(model));
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                if (!await ExistsById(id))
                {
                    return(NotFound());
                }
                else
                {
                    return(BadRequest());
                }
            }
        }
示例#4
0
        public ActionResult Index(long id)
        {
            var model = new LegalPersonModel();

            if (id > 0)
            {
                model = legalPersonAppService.GetById(id);
            }

            return(View(model));
        }
        public void TestMethod1()
        {
            // Arrange
            LegalPersonModel       legalPerson = new LegalPersonModel("JCGETSOFTWARE", "1233333", "11298978699", "12321321");
            LegalPersonCoordinator coordinator = new LegalPersonCoordinator(legalPerson);

            // Act
            Investigation investigation = coordinator.Run();

            // Assert
            Assert.AreEqual(investigation.Completed, true);
        }
        public void TestMethod1()
        {
            // Arrange
            var exampleLegalPerson = new LegalPersonModel
            {
                CNPJ = "87676557000125"
            };

            // Act
            var coordinator = new LegalPersonCoordinator(exampleLegalPerson).StartSearch();

            // Assert
            Assert.AreEqual(coordinator.ResultadoFinal.Completed, true);
        }
示例#7
0
 public void Save(LegalPersonModel LegalPersonModel)
 {
     legalPersonService.Save(
         LegalPersonModel.Id,
         LegalPersonModel.CompanyName,
         LegalPersonModel.TradeName,
         LegalPersonModel.CNPJ,
         LegalPersonModel.ZipCode,
         LegalPersonModel.Country,
         LegalPersonModel.State,
         LegalPersonModel.City,
         LegalPersonModel.Address1,
         LegalPersonModel.Address2
         );
 }
        public void TestMethod1()
        {
            // Arrange
            var exampleLegalPerson = new LegalPersonModel
            {
                NomeFantasia  = "PETROBRASIL",
                CNPJ          = "1111111111",
                CPFDoFundador = "2222222222",
                Contador      = "333333333",
            };
            var coordinator = new LegalPersonCoordinator(exampleLegalPerson);

            // Act
            var investigation = coordinator.Run();

            // Assert
            Assert.AreEqual(investigation.Completed, true);
        }
示例#9
0
        public async Task <ActionResult <LegalPersonModel> > Create(LegalPersonModel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            try
            {
                var id = await _repository.Save(model);

                return(Ok(model));
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                return(BadRequest());
            }
        }
示例#10
0
 public ActionResult Save(LegalPersonModel model)
 {
     try
     {
         if (ModelState.IsValid)
         {
             legalPersonAppService.Save(model);
             return(GetJsonSimpleSuccess());
         }
         else
         {
             return(GetJsonErrorFromModalState());
         }
     }
     catch (Exception ex)
     {
         var errors = new List <string>();
         errors.Add("You can not save this person!");
         errors.Add(ex.Message);
         return(GetJsonSimpleErrorToSwal(errors));
     }
 }
 public async Task <bool> Save(LegalPersonModel legalPerson)
 {
     await new MongoDbContext().LegalPerson.InsertOneAsync(legalPerson);
     return(true);
 }
        public async Task <bool> UpdateById(Guid id, LegalPersonModel legalPerson)
        {
            var result = await new MongoDbContext().LegalPerson.ReplaceOneAsync(x => x.Id == id, legalPerson);

            return(result != null);
        }
        //private CrawlerResult Result { get; set; }

        public LegalPersonCoordinator(LegalPersonModel legalPerson)
        {
            _find = legalPerson;
        }
 public LegalPersonCoordinator(LegalPersonModel legalPerson)
 {
     AddModule(new ArispCrawler(legalPerson.Type, legalPerson.CNPJ));
     AddModule(new SivecCrawler());
 }
        static void Main(string[] args)
        {
            Console.WriteLine("Iniciando a busca");

            #region objetos de teste
            var exampleLegalPerson = new LegalPersonModel
            {
                NomeFantasia  = "PETROBRASIL",
                CNPJ          = "1111111111",
                CPFDoFundador = "2222222222",
                Contador      = "333333333",
            };

            var examplePhysicalPerson = new PhysicalPersonModel()
            {
                NomeCompleto     = "JULIO AVILA",
                CPF              = "1111111111",
                RG               = "22222222222",
                DataDeNascimento = "23/01/1997",
                NomeDaMae        = "SELMA AVILA"
            };
            #endregion

            try
            {
                using (var db = new DataBaseContext())
                {
                    Console.WriteLine("running migrations");
                    db.Database.Migrate();

                    Console.WriteLine("saving legal person");
                    db.LegalPerson.Add(exampleLegalPerson);
                    db.SaveChanges();

                    var empresas = db.LegalPerson;
                    foreach (var empresa in empresas)
                    {
                        Console.WriteLine($"Empresa: {empresa.NomeFantasia}");
                        var crawler = new LegalPersonCoordinator(empresa);
                        var result  = crawler.Run();
                        Console.WriteLine("Completou a busca? {0}", result.Completed);
                    }

                    Console.WriteLine("saving physical person");
                    db.PhysicalPerson.Add(examplePhysicalPerson);
                    db.SaveChanges();

                    var pessoas = db.PhysicalPerson;
                    foreach (var pessoa in pessoas)
                    {
                        Console.WriteLine($"Pessoa: {pessoa.NomeCompleto}");
                        var crawler = new PhysicalPersonCoordinator(pessoa);
                        var result  = crawler.Run();
                        Console.WriteLine("Completou a busca? {0}", result.Completed);
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("Search execution error: {0}", e.Message);
            }

            Console.WriteLine("finished application");
            Console.ReadKey();
        }