Exemplo n.º 1
0
        public async Task <int> AddUserAsync(AddUserRequest addUserRequest)
        {
            try
            {
                addUserRequest.Password = Utility.Encryptdata(addUserRequest.Password.ToString());
                if (UserExist(addUserRequest.Email))
                {
                    // "User already exists.";
                    return(-1);
                }
                using var databaseConnection = _dbConnectionFactory.GetConnection();
                using var transaction        = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled);
                var rowsAffected = await databaseConnection.ExecuteAsync(SqlQueries.InsertUserQuery, new
                {
                    addUserRequest.Username,
                    addUserRequest.Password,
                    addUserRequest.Email
                });

                transaction.Complete();
                return(rowsAffected);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 2
0
        private bool VerifyPasswordHash(string password, string DBpassword)
        {
            string EncrPassword = Utility.Encryptdata(password);

            if (EncrPassword == DBpassword)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }