public void AddUserDataToSession(CurrentProfileSession profileSession) { try { HttpContext.Current.Session.Add("CurrentUser", profileSession); } catch (Exception ex) { Logger.Error("Error - Adding Current user data to session state \r\n{0} \r\n{1}",ex.Message,ex.StackTrace); } }
public void AddUserDataToSession(CurrentProfileSession profileSession) { try { HttpContext.Current.Session.Add("CurrentUser", profileSession); } catch (Exception ex) { Logger.Error("Error - Adding Current user data to session state \r\n{0} \r\n{1}", ex.Message, ex.StackTrace); } }
private string GetMaster(CurrentProfileSession profileData) { if (!HttpContext.Current.User.Identity.IsAuthenticated) { Logger.Debug("Layout - Setting Layout to Anonymous User"); return "_AnonymousUserLayout"; } else if (profileData.Role == "admin") { Logger.Debug("Layout - Setting Layout to admin"); return "_AdminLayout"; } else if (profileData.Role == "basicuser" || profileData.Role == "courseowner") { Logger.Debug("Layout - Setting Layout to Logged User"); return "_LoggedUserLayout"; } return String.Empty; }
//todotest public CurrentProfileSession GetCurrentUserDataFromSession() { try { if (HttpContext.Current != null) { var obj = HttpContext.Current.Session["CurrentUser"]; if (obj != null) { Logger.Debug("retrieving Current user data from session state "); var currentUserSession = obj as CurrentProfileSession; if (currentUserSession != null) { return(currentUserSession); } else { return(null); } } else { Logger.Debug("Adding Current user data to session state "); var profile = _profileService.GetByNameSignature(HttpContext.Current.User.Identity.Name); var currentProfileSession = new CurrentProfileSession(profile); AddUserDataToSession(currentProfileSession); return(currentProfileSession); } } else { return(null); } } catch (Exception ex) { Logger.Error("Error - Retrieving Current user data from session state \r\n{0} \r\n{1}", ex.Message, ex.StackTrace); return(null); } }
//todotest public CurrentProfileSession GetCurrentUserDataFromSession() { try { if (HttpContext.Current != null) { var obj = HttpContext.Current.Session["CurrentUser"]; if (obj != null) { Logger.Debug("retrieving Current user data from session state "); var currentUserSession = obj as CurrentProfileSession; if (currentUserSession != null) return currentUserSession; else return null; } else { Logger.Debug("Adding Current user data to session state "); var profile = _profileService.GetByNameSignature(HttpContext.Current.User.Identity.Name); var currentProfileSession = new CurrentProfileSession(profile); AddUserDataToSession(currentProfileSession); return currentProfileSession; } } else return null; } catch (Exception ex) { Logger.Error("Error - Retrieving Current user data from session state \r\n{0} \r\n{1}", ex.Message, ex.StackTrace); return null; } }