Ejemplo n.º 1
0
 /// <summary>
 /// Return how we want to display the user's name in the UI. Currently set to Username, could be changed to First/Last, etc,
 /// </summary>
 /// <param name="FormsAuthService"></param>
 /// <returns></returns>
 public static string GetUserFriendlyName(IFormsAuthenticationService FormsAuthService)
 {
     return HttpContext.Current.Cache.GetOrStore<string>(
         GetUserSignInKey(FormsAuthService, UserFriendlyNameKey),
         () =>
         {
             if (FormsAuthService.IsAuthenticated())
             {
                 using (SiteDB db = new SiteDB())
                 {
                     var user = UserRepository.GetUser(db, FormsAuthService.GetCurrentUserId());
                     if (user != null)
                     {
                         return user.Username;
                     }
                     else
                     {
                         return "";
                     }
                 }
             }
             else
             {
                 return "";
             }
         }
     );
 }
 /// <summary>
 /// Return how we want to display the user's name in the UI. Currently set to Username, could be changed to First/Last, etc,
 /// </summary>
 /// <param name="FormsAuthService"></param>
 /// <returns></returns>
 public static string GetUserFriendlyName(IFormsAuthenticationService FormsAuthService)
 {
     return HttpContext.Current.Cache.GetOrStore<string>(
         GetUserSignInKey(FormsAuthService, UserFriendlyNameKey),
         () =>
         {
             if (FormsAuthService.IsAuthenticated())
             {
                 var userRepository = new UserRepository(MvcApplication.SessionFactory.OpenSession());
                 var user = userRepository.GetUser(FormsAuthService.GetCurrentUserName());
                 if (user != null)
                 {
                     return user.Username;
                 }
                 else
                 {
                     return "";
                 }
             }
             else
             {
                 return "";
             }
         }
     );
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Return how we want to display the user's name in the UI. Currently set to Username, could be changed to First/Last, etc,
 /// </summary>
 /// <param name="FormsAuthService"></param>
 /// <returns></returns>
 public static string GetUserFriendlyName(IFormsAuthenticationService FormsAuthService)
 {
     return(HttpContext.Current.Cache.GetOrStore <string>(
                GetUserSignInKey(FormsAuthService, UserFriendlyNameKey),
                () =>
     {
         if (FormsAuthService.IsAuthenticated())
         {
             using (SiteDB db = new SiteDB())
             {
                 var user = UserRepository.GetUser(db, FormsAuthService.GetCurrentUserId());
                 if (user != null)
                 {
                     return user.Username;
                 }
                 else
                 {
                     return "";
                 }
             }
         }
         else
         {
             return "";
         }
     }
                ));
 }