コード例 #1
0
        // TODO  Create a PageIdManager that wraps ConfigurationManager and does the convert for us.

        private static int CreateHouseholdRecord(User newUserData, string token){
            int recordId;

            Dictionary<string, object> householdDictionary = new Dictionary<string, object>();
            householdDictionary["Household_Name"] = newUserData.lastName;
            householdDictionary["Congregation_ID"] = Convert.ToInt32(ConfigurationManager.AppSettings["Congregation_Default_ID"]);
            householdDictionary["Household_Source_ID"] = Convert.ToInt32(ConfigurationManager.AppSettings["Household_Default_Source_ID"]);

            recordId = MinistryPlatformService.CreateRecord(Convert.ToInt32(ConfigurationManager.AppSettings["Households"]), householdDictionary, token);

            return recordId;
        }
コード例 #2
0
        private static int CreateContactRecord(User newUserData, string token, int householdRecordID)
        {
            int recordId;

            Dictionary<string, object> contactDictionary = new Dictionary<string, object>();
            contactDictionary["First_Name"] = newUserData.firstName;
            contactDictionary["Last_Name"] = newUserData.lastName;
            contactDictionary["Email_Address"] = newUserData.email;
            contactDictionary["Company"] = false; // default
            contactDictionary["Display_Name"] = newUserData.lastName + ", " + newUserData.firstName;
            contactDictionary["Nickname"] = newUserData.firstName;
            contactDictionary["Household_Position_ID"] = Convert.ToInt32(ConfigurationManager.AppSettings["Household_Position_Default_ID"]);
            contactDictionary["Household_ID"] = householdRecordID;

            recordId = MinistryPlatformService.CreateRecord(Convert.ToInt32(ConfigurationManager.AppSettings["Contacts"]), contactDictionary, token);

            return recordId;
        }
コード例 #3
0
        public Dictionary<string, string>RegisterPerson(User newUserData)
        {
            var apiUser = this._configurationWrapper.GetEnvironmentVarAsString("API_USER");
            var apiPassword = this._configurationWrapper.GetEnvironmentVarAsString("API_PASSWORD");
            var authData = AuthenticationService.authenticate(apiUser, apiPassword);
            var token = authData["token"].ToString();

            int householdRecordID = CreateHouseholdRecord(newUserData,token);
            int contactRecordID = CreateContactRecord(newUserData,token,householdRecordID);
            int contactHouseholdRecordID = CreateContactHouseholdRecord(token,householdRecordID,contactRecordID);
            int userRecordID = CreateUserRecord(newUserData, token, contactRecordID);
            int userRoleRecordID = CreateUserRoleSubRecord(token, userRecordID);
            int participantRecordID = CreateParticipantRecord(token, contactRecordID);

            CreateNewUserSubscriptions(contactRecordID, token);

            // TODO Contingent on cascading delete via contact
            Dictionary<string, string> returnValues = new Dictionary<string, string>();
            returnValues["firstname"] = newUserData.firstName;
            returnValues["lastname"] = newUserData.lastName;
            returnValues["email"] = newUserData.email;
            returnValues["password"] = newUserData.password; //TODO Conisder encrypting the password on the user model
            return returnValues;
        }
コード例 #4
0
        private static int CreateUserRecord(User newUserData, string token, int contactRecordID)
        {
            int recordId;

            Dictionary<string, object> userDictionary = new Dictionary<string, object>();
            userDictionary["First_Name"] = newUserData.firstName;
            userDictionary["Last_Name"] = newUserData.lastName;
            userDictionary["User_Email"] = newUserData.email;
            userDictionary["Password"] = newUserData.password;
            userDictionary["Company"] = false; // default
            userDictionary["Display_Name"] = userDictionary["First_Name"];
            userDictionary["Domain_ID"] = 1;
            userDictionary["User_Name"] = userDictionary["User_Email"];
            userDictionary["Contact_ID"] = contactRecordID;

            recordId = MinistryPlatformService.CreateRecord(Convert.ToInt32(ConfigurationManager.AppSettings["Users"]), userDictionary, token, true);

            return recordId;
        }