/// <summary> /// Delete the profile values /// </summary> /// <param name="profileID">The profile id..</param> /// <returns>True if complete; else false.</returns> private bool DeleteProfileValue(long profileID) { // Attempt to delete the user. bool ret = new Nequeo.DataAccess.CloudInteraction.Data.Extension.ProfileValue(). Delete.DeleteItemPredicate( u => (u.ProfileID == profileID) ); // Return the result of the deletion. return(ret); }
/// <summary> /// Get the profile value for the property name. /// </summary> /// <param name="profileID">The profile id.</param> /// <param name="propertyName">The property name to serach for.</param> /// <returns>The profile value; else null.</returns> private Nequeo.DataAccess.CloudInteraction.Data.ProfileValue GetSpecificPropertyValue(long profileID, string propertyName) { // Get the user data. Nequeo.DataAccess.CloudInteraction.Data.Extension.ProfileValue profileExt = new Nequeo.DataAccess.CloudInteraction.Data.Extension.ProfileValue(); Nequeo.DataAccess.CloudInteraction.Data.ProfileValue profile = profileExt.Select.SelectDataEntity( u => (u.ProfileID == profileID) && (u.PropertyName == propertyName) ); // Return the profile. return(profile); }
/// <summary> /// Sets the values of the specified group of property settings. /// </summary> /// <param name="context">A System.Configuration.SettingsContext describing the current application usage.</param> /// <param name="collection">A System.Configuration.SettingsPropertyValueCollection representing the group /// of property settings to set.</param> public void SetPropertyValues(System.Configuration.SettingsContext context, System.Configuration.SettingsPropertyValueCollection collection) { string username = (string)context["UserName"]; bool isAuthenticated = (bool)context["IsAuthenticated"]; // Get the profile for the current user name. Nequeo.DataAccess.CloudInteraction.Data.Profile profile = GetSpecificProfile(username); // If a profile exits. if (profile != null) { long profileID = profile.ProfileID; // For each property setting. foreach (SettingsPropertyValue pv in collection) { bool propertyFound = false; string propertyName = pv.Property.Name; // Get the value for the current property name. object value = GetProfilePropertyValue(profile, isAuthenticated, propertyName, out propertyFound); // If the property has been found. if (propertyFound) { // Update the property. bool retUpdate = new Nequeo.DataAccess.CloudInteraction.Data.Extension.ProfileValue(). Update.UpdateItemPredicate( new Data.ProfileValue() { PropertyValue = pv.PropertyValue.ToString() }, u => (u.ProfileID == profileID) && (u.PropertyName == propertyName) ); } else { // Insert the property. bool retInsert = new Nequeo.DataAccess.CloudInteraction.Data.Extension.ProfileValue(). Insert.InsertItem( new Data.ProfileValue() { ProfileID = profileID, PropertyName = propertyName, PropertyType = "System.String", PropertyValue = pv.PropertyValue.ToString() } ); } } // Updates the LastActivityDate and LastUpdatedDate values when profile properties UpdateActivityDates(username, isAuthenticated, false); } else { // Make sure that the profile exists for the username if authenticated. if (isAuthenticated) { throw new ProviderException("Profile username : "******" does not exist."); } } }