Exemplo n.º 1
0
        /// <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);
        }
Exemplo n.º 2
0
 /// <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()));
 }
Exemplo n.º 3
0
        public Session_Tests()
        {
            Building(builder => { }).Ok();

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

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