public void AlterEmail(string email) { ValidatorRule.New() .With(string.IsNullOrEmpty(email) || !Validators.IsEmail(email), Resource.EmailInvalid) .ThrowExceptionIfExist(); Email = email; }
public void AlterCpf(string cpf) { ValidatorRule.New() .With(string.IsNullOrEmpty(cpf) || !Validators.IsCpf(cpf), Resource.CpfInvalid) .ThrowExceptionIfExist(); Cpf = cpf; }
public void AlterName(string name) { ValidatorRule.New() .With(string.IsNullOrEmpty(name), Resource.NameInvalid) .ThrowExceptionIfExist(); Name = name; }
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; }
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); }