internal static async Task <NotificationAction> GetScheduledNotification() { var value = await CookieProperty.Get(COOKIE_KEY); if (value.IsEmpty()) { return(null); } CookieProperty.Remove(COOKIE_KEY); return(JsonConvert.DeserializeObject <NotificationAction>(value)); }
internal static NotificationAction GetScheduledNotification() { var value = CookieProperty.Get(COOKIE_KEY).GetAlreadyCompletedResult(); if (value.IsEmpty()) { return(null); } CookieProperty.Remove(COOKIE_KEY); return(JsonConvert.DeserializeObject <NotificationAction>(value)); }
static Dictionary <string, string> ReadAllSortExpressionSettings() { var cookie = CookieProperty.Get(LIST_CONTAINERS_SORT_EXPRESSION_COOKIE_NAME); if (cookie.IsEmpty()) { return(new Dictionary <string, string>()); } var items = cookie.Split(new[] { '&' }, StringSplitOptions.RemoveEmptyEntries).Trim(); var settings = items.Select(a => a.Split('=').Trim().ToArray()).Where(x => x.Length == 2).ToArray(); return(settings.ToDictionary(a => a[0], a => a[1])); }
public IUser LoadUser(System.Security.Principal.IPrincipal principal) { var userId = ApplicationEventManager.GetCurrentUserId(principal); if (userId == null) { var cookieValue = CookieProperty.Get <string>(".ASPXAUTH", defaultValue: null); if (cookieValue.HasValue()) { userId = FormsAuthentication.Decrypt(cookieValue).Name; } } if (userId == null) { return(null); // throw new Exception("There is no current user logged in."); } return(Database.Get <IUser>(userId)); }
/// <summary> /// Removes the notification actions from the current set of specified actions, and schedules them in the next request through the cookie. /// </summary> internal static void ScheduleForNextRequest(List <object> actions) { var notificationActions = actions.OfType <NotificationAction>().ToList(); if (notificationActions.None()) { return; } notificationActions.Do(a => actions.Remove(a)); var json = JsonConvert.SerializeObject(new NotificationAction { Notify = notificationActions.Select(x => x.Notify).ToLinesString(), Obstruct = notificationActions.First().Obstruct, Style = notificationActions.First().Style }); CookieProperty.Set(COOKIE_KEY, json); }
internal void SetSortExpressionInCookie(string newSortExpression) { try { var items = ReadAllSortExpressionSettings(); if (items.ContainsKey(SortExpressionKey)) { items.Remove(SortExpressionKey); } // Add it to the end of the list: items.Add(SortExpressionKey, newSortExpression); CookieProperty.Set(LIST_CONTAINERS_SORT_EXPRESSION_COOKIE_NAME, CreateNewCookieValue(items)); } catch { // Problem with cookie. Ignore. } }
public static void SetOriginalUrl(string value) => CookieProperty.Set("Impersonation.Original.Url", value);
public static async Task <string> GetOriginalUrl() => (await CookieProperty.Get("Impersonation.Original.Url")).Or("~/");
static void SetImpersonationToken(string value) => CookieProperty.Set("Impersonation.Token", value);
public T Get <T>() => CookieProperty.Get <T>();