/// <summary> /// Load a ReviewerProfile object for given email address /// </summary> /// <param name="emailAddress">Email address to load ReviewerProfile object for</param> /// <returns>ReviewerProfile object for given email address</returns> public static ReviewerProfile LoadForEmail(string emailAddress) { if (string.IsNullOrEmpty(emailAddress)) { return(null); } StringBuilder selectQuery = new StringBuilder(); selectQuery.Append("SELECT " + ReviewerProfile.GetColumnNames(string.Empty)); selectQuery.Append(" FROM ac_ReviewerProfiles"); selectQuery.Append(" WHERE Email = @emailAddress"); Database database = Token.Instance.Database; DbCommand selectCommand = database.GetSqlStringCommand(selectQuery.ToString()); database.AddInParameter(selectCommand, "@emailAddress", DbType.String, emailAddress); ReviewerProfile reviewerProfile = null; using (IDataReader dr = database.ExecuteReader(selectCommand)) { if (dr.Read()) { reviewerProfile = new ReviewerProfile(); ReviewerProfile.LoadDataReader(reviewerProfile, dr); } dr.Close(); } return(reviewerProfile); }
/// <summary> /// Loads the given ReviewerProfile object from the given database data reader. /// </summary> /// <param name="reviewerProfile">The ReviewerProfile object to load.</param> /// <param name="dr">The database data reader to read data from.</param> public static void LoadDataReader(ReviewerProfile reviewerProfile, IDataReader dr) { //SET FIELDS FROM ROW DATA reviewerProfile.ReviewerProfileId = dr.GetInt32(0); reviewerProfile.Email = dr.GetString(1); reviewerProfile.DisplayName = dr.GetString(2); reviewerProfile.Location = NullableData.GetString(dr, 3); reviewerProfile.EmailVerified = dr.GetBoolean(4); reviewerProfile.EmailVerificationCode = NullableData.GetGuid(dr, 5); reviewerProfile.IsDirty = false; }
/// <summary> /// Finds out if email verification is required for given user /// </summary> /// <param name="profile">The reviewer profile to check for</param> /// <param name="user">The user to check for</param> /// <returns>true if email verification is required, false otherwise</returns> public static bool EmailVerificationRequired(ReviewerProfile profile, User user) { if (profile.EmailVerified) { return(false); } StoreSettingCollection settings = Token.Instance.Store.Settings; switch (settings.ProductReviewEmailVerification) { case UserAuthFilter.None: return(false); case UserAuthFilter.Anonymous: return(user.IsAnonymous); case UserAuthFilter.Registered: return(!user.IsAnonymous); default: return(true); } }