Example #1
0
        public void AlterEmail(string email)
        {
            ValidatorRule.New()
            .With(string.IsNullOrEmpty(email) || !Validators.IsEmail(email), Resource.EmailInvalid)
            .ThrowExceptionIfExist();

            Email = email;
        }
Example #2
0
        public void AlterCpf(string cpf)
        {
            ValidatorRule.New()
            .With(string.IsNullOrEmpty(cpf) || !Validators.IsCpf(cpf), Resource.CpfInvalid)
            .ThrowExceptionIfExist();

            Cpf = cpf;
        }
Example #3
0
        public void AlterName(string name)
        {
            ValidatorRule.New()
            .With(string.IsNullOrEmpty(name), Resource.NameInvalid)
            .ThrowExceptionIfExist();

            Name = name;
        }
Example #4
0
        public PersonModel(string name, string cpf, string email)
        {
            ValidatorRule.New()
            .With(string.IsNullOrEmpty(name), Resource.NameInvalid)
            .With(string.IsNullOrEmpty(cpf) || !Validators.IsCpf(cpf), Resource.CpfInvalid)
            .With(string.IsNullOrEmpty(email) || !Validators.IsEmail(email), Resource.EmailInvalid)
            .ThrowExceptionIfExist();

            Name  = name;
            Cpf   = cpf;
            Email = email;
        }
Example #5
0
        public async Task InsertAsync(PersonViewModel personViewModel)
        {
            var personWithSameCpf = await _personRepository.GetbyCpfAsync(personViewModel.Cpf);

            ValidatorRule.New()
            .With(personWithSameCpf != null, Resource.CpfExist)
            .ThrowExceptionIfExist();

            var person = new PersonModel(personViewModel.Name, personViewModel.Cpf, personViewModel.Email);

            await _personRepository.InsertAsync(person);
        }