/// <summary>
        ///     Gets current User's Id.
        ///     Throws <see cref="StoveException" /> if <see cref="IStoveSession.UserId" /> is null.
        /// </summary>
        /// <param name="session">Session object.</param>
        /// <returns>Current User's Id.</returns>
        public static long GetUserId(this IStoveSession session)
        {
            if (!session.UserId.HasValue)
            {
                throw new StoveException("Session.UserId is null! Probably, user is not logged in.");
            }

            return(session.UserId.Value);
        }
 /// <summary>
 ///     Creates <see cref="UserIdentifier" /> from given session.
 ///     Returns null if <see cref="IStoveSession.UserId" /> is null.
 /// </summary>
 /// <param name="session">The session.</param>
 public static UserIdentifier ToUserIdentifier(this IStoveSession session)
 {
     return(session.UserId == null
         ? null
         : new UserIdentifier(session.GetUserId()));
 }
Esempio n. 3
0
        public Session_Tests()
        {
            Building(builder => { }).Ok();

            _session = The <IStoveSession>();
        }
Esempio n. 4
0
        public Session_Tests()
        {
            Building(builder => { }).Ok();

            _session = LocalResolver.Resolve <IStoveSession>();
        }