예제 #1
0
		/// <summary>
		/// Gets the profile for the specified user.
		/// </summary>
		/// <param name="userName">The account name for the user whose profile settings are to be retrieved.</param>
		/// <returns>Gets the profile for the specified user.</returns>
		public static ProfileEntity GetProfile(string userName)
		{
			if (String.IsNullOrEmpty(userName))
				throw new ArgumentNullException("userName");

			ProfileBase p = ProfileBase.Create(userName, Util.IsAuthenticated);

			ProfileEntity pe = new ProfileEntity();
			pe.UserName = userName;

			bool showMediaObjectMetadata;
			if (Boolean.TryParse(p.GetPropertyValue(Constants.SHOW_METADATA_PROFILE_NAME).ToString(), out showMediaObjectMetadata))
			{
				pe.ShowMediaObjectMetadata = showMediaObjectMetadata;
			}

			int userAlbumId;
			if (Int32.TryParse(p.GetPropertyValue(Constants.USER_ALBUM_ID_PROFILE_NAME).ToString(), out userAlbumId))
			{
				pe.UserAlbumId = userAlbumId;
			}

			bool enableUserAlbum;
			if (Boolean.TryParse(p.GetPropertyValue(Constants.ENABLE_USER_ALBUM_PROFILE_NAME).ToString(), out enableUserAlbum))
			{
				pe.EnableUserAlbum = enableUserAlbum;
			}

			return pe;
		}
예제 #2
0
		/// <summary>
		/// Saves the profile to the data store for the currently logged on user.
		/// </summary>
		/// <param name="userProfile">The user profile to save to the data store.</param>
		public static void SaveProfile(ProfileEntity userProfile)
		{
			if (userProfile == null)
				throw new ArgumentNullException("userProfile");

			if (String.IsNullOrEmpty(userProfile.UserName))
				throw new ArgumentNullException("userProfile.UserName", "The UserName property of the userProfile parameter is null or empty.");

			ProfileBase p = ProfileBase.Create(userProfile.UserName, Util.IsAuthenticated);

			// All users - authenticated and anonymous - have the show metadata profile property
			p.SetPropertyValue(Constants.SHOW_METADATA_PROFILE_NAME, userProfile.ShowMediaObjectMetadata.ToString());

			if (!p.IsAnonymous)
			{
				// Only save these for logged-on users.
				p.SetPropertyValue(Constants.USER_ALBUM_ID_PROFILE_NAME, userProfile.UserAlbumId);

				p.SetPropertyValue(Constants.ENABLE_USER_ALBUM_PROFILE_NAME, userProfile.EnableUserAlbum.ToString());
			}
			
			p.Save();
		}
예제 #3
0
		private static void SaveProfile(ProfileEntity userProfile)
		{
			// Get reference to user's album. We need to do this *before* saving the profile, because if the user disabled their user album,
			// this method will return null after saving the profile.
			IAlbum album = UserController.GetUserAlbum();

			if (!userProfile.EnableUserAlbum)
			{
				userProfile.UserAlbumId = 0;
			}

			ProfileController.SaveProfile(userProfile);

			if (!userProfile.EnableUserAlbum)
			{
				AlbumController.DeleteAlbum(album);
			}
		}