Example #1
0
        public async Task <string> AddAsync(UserRegisterViewModel userRegister)
        {
            if (await EmailAlreadyExists(userRegister.UserEmail))
            {
                return("Esse email ja está cadastrado");
            }

            userRegister.UserPassword = _cryptographyService.CreateEncryption(userRegister.UserPassword);

            var user = _mapper.Map <UserRegisterViewModel, User>(userRegister);

            var affectedRows = await _userRepository.AddAsync(user);

            if (affectedRows <= 0)
            {
                return("Erro ao cadastrar");
            }

            return(string.Empty);
        }