Exemple #1
0
        public override bool Validate()
        {
            var regex = new Regex(@"\D");

            Cnpj = regex.Replace(Cnpj ?? string.Empty, string.Empty);

            if (Cnpj.Length != 14)
            {
                ValidationErrors.Add("O campo CNPJ de Empresa deve ter 14 números.");
            }

            if (string.IsNullOrWhiteSpace(Uf) || Uf.Length != 2)
            {
                ValidationErrors.Add("O campo UF de Empresa deve conter dois caracteres.");
            }

            Uf = Uf?.ToUpper();

            if (string.IsNullOrWhiteSpace(NomeFantasia))
            {
                ValidationErrors.Add("O nome da empresa é obrigatório.");
            }

            if (NomeFantasia?.Length > 80)
            {
                NomeFantasia = NomeFantasia?.Substring(0, 80);
            }

            return(ValidationErrors.Count == 0);
        }
Exemple #2
0
 private void Calcular()
 {
     if (Uf.ToUpper() == "SP")
     {
         Percentual = 0.2m;
     }
     else
     {
         Percentual = 0.3m;
     }
 }