public void Save(SystemUserViewModel systemUserViewModel) { if (_systemUserRepository.GetExactEmail(systemUserViewModel.Email) != null) { throw new BusisnessException("Já existe um usuário cadastrado com este e-mail"); } var passwordPower = UtilValidation.GetPasswordPower(systemUserViewModel.Password); if ((int)passwordPower < 3) { throw new BusisnessException($"A senha digitada não atende os requisitos mínimos - Nível {passwordPower}"); } if (systemUserViewModel.Password != systemUserViewModel.ConfirmPassword) { throw new BusisnessException($"A senha digitada não é igual a confirmação de senha"); } var model = _mapper.Map <SystemUserViewModel, SystemUser>(systemUserViewModel); model.Password = EncryptData.EncryptPassword(model.Password); _systemUserRepository.Add(model); }
public SystemUser GetExactEmail(string email) { return(_systemUserRepository.GetExactEmail(email)); }