public void Create(Usuario obj)
 {
     //verificar se o email informado ja está cadastrado na base
     if (usuarioRepository.Count(u => u.Email.Equals(obj.Email)) > 0)
     {
         throw new EmailUnicoException(); //lançar uma exceção customizada
     }
     //criptografando a senha
     obj.Senha = cryptography.Encrypt(obj.Senha);
     usuarioRepository.Create(obj);
 }
예제 #2
0
        public void Create(Usuario obj)
        {
            if (_usuarioRepository.Count(u => u.Email.Equals(obj.Email)) > 0)
            {
                throw new EmaiUnicoException();
            }

            obj.Senha = _cryptography.Encrypt(obj.Senha);

            _usuarioRepository.Create(obj);
        }
예제 #3
0
        public Usuario GetByLoginAndSenha(string login, string senha)
        {
            var registro = usuarioRepository.GetByLoginAndSenha(login, cryptography.Encrypt(senha));

            if (registro != null)
            {
                return(registro);
            }
            else
            {
                throw new Exception("Usuario não foi encontrado.");
            }
        }
예제 #4
0
        public override void Create(UsuarioEntity entity)
        {
            #region Email deve ser único

            if (unitOfWork.UsuarioRepository.Get(u => u.Email.Equals(entity.Email)) != null)
            {
                throw new EmailDeveSerUnicoException(entity.Email);
            }

            #endregion

            #region Criptografar a senha do usuário

            entity.Senha = cryptography.Encrypt(entity.Senha);

            #endregion

            base.Create(entity);
        }