Beispiel #1
0
        //Incluir um registro
        public string Insert(Contato contato)
        {
            StringBuilder erros = new StringBuilder();

            if (string.IsNullOrWhiteSpace(contato.Fone))
            {
                erros.AppendLine("O telefone deve ser informado.");
            }

            if (!string.IsNullOrWhiteSpace(contato.Fone))
            {
                if (contato.Fone.Length > 20)
                {
                    erros.AppendLine("O telefone não pode conter mais que 20 caracteres.");
                }
            }

            if (string.IsNullOrWhiteSpace(contato.Email))
            {
                erros.AppendLine("O email deve ser informada.");
            }

            if (!string.IsNullOrWhiteSpace(contato.Email))
            {
                if (contato.Email.Length > 50)
                {
                    erros.AppendLine("O email não pode conter mais que 50 caracteres.");
                }
            }

            if (erros.Length != 0)
            {
                return(erros.ToString());
            }

            string respostaDB = dal.Insert(contato);

            return(respostaDB);
        }