Created
June 30, 2016 20:11
-
-
Save islaytitans/e442f33a2b77d4d26417472c667c61ed to your computer and use it in GitHub Desktop.
Sitecore Personalization rule for levelled gated access
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class GrantGatedAccessLevelledCondition<T> : IntegerComparisonCondition<T> where T : RuleContext | |
{ | |
public int No { get; set; } | |
... | |
protected override bool Execute(T ruleContext) | |
{ | |
string cookieName = Utility.DefineCookieName(); | |
if (HttpContext.Current.Request.Cookies[cookieName] == null) | |
return false; | |
var actualLevel = HttpContext.Current.Request.Cookies[cookieName].Value; | |
if (string.IsNullOrEmpty(actualLevel)) | |
return false; | |
int actualLevelInt; | |
if (!int.TryParse(actualLevel, out actualLevelInt)) | |
return false; | |
Value = No; | |
return Compare(actualLevelInt); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment