Exemplo n.º 1
0
        private string ValidateCNPJ(string CNPJ)
        {
            var helper = new CNPJHelper();

            if (string.IsNullOrEmpty(CNPJ) || !helper.IsCNPJ(CNPJ))
            {
                throw new CustomExceptions("CNPJ incorreto");
            }

            return(helper.Clean(CNPJ));
        }
Exemplo n.º 2
0
 private async Task Validate(string CNPJ, CNPJHelper helper)
 {
     if (!helper.IsCNPJ(CNPJ))
     {
         throw new CustomExceptions("CNPJ incorreto");
     }
     else if (!await _companyRepository.AnyAsync(x => x.CNPJ.Equals(helper.Clean(CNPJ))))
     {
         throw new CustomExceptions("CNPJ não encontrado na base de dados");
     }
 }