Esempio n. 1
0
        /// <summary>
        /// Get user id and return Guid.
        /// </summary>
        /// <param name="session">The <see cref="IEasyNetSession"/></param>
        /// <returns>The user id.</returns>
        /// <exception cref="EasyNetException">Throw exception if EasyNetSession.UserId is null.</exception>
        /// <exception cref="FormatException">Throw exception if the user id is not in the correct format.</exception>
        public static Guid GetGuidUserId(this IEasyNetSession session)
        {
            Check.NotNull(session, nameof(session));

            if (string.IsNullOrEmpty(session.UserId))
            {
                throw new EasyNetException("EasyNetSession.UserId is null. Probably, user is not logged in.");
            }

            return(Guid.Parse(session.UserId));
        }
Esempio n. 2
0
        /// <summary>
        /// Get user id and return int.
        /// </summary>
        /// <param name="session">The <see cref="IEasyNetSession"/></param>
        /// <returns>The user id or null.</returns>
        /// <exception cref="FormatException">Throw exception if the user id is not in the correct format.</exception>
        /// <exception cref="OverflowException">Throw exception if the user id is greater than <see cref="Int64.MaxValue"/>.</exception>
        public static long?GetLongUserIdOrNull(this IEasyNetSession session)
        {
            Check.NotNull(session, nameof(session));

            if (string.IsNullOrEmpty(session.UserId))
            {
                return(null);
            }

            return(long.Parse(session.UserId));
        }
Esempio n. 3
0
 public EfCoreContext(DbContextOptions options, ICurrentUnitOfWorkProvider currentUnitOfWorkProvider = null, IEasyNetSession session = null) : base(options, currentUnitOfWorkProvider, session)
 {
 }
 public EasyNetDbContext(DbContextOptions options, ICurrentUnitOfWorkProvider currentUnitOfWorkProvider, IEasyNetSession session) : base(options)
 {
     CurrentUnitOfWorkProvider = currentUnitOfWorkProvider;
     EasyNetSession            = session ?? NullEasyNetSession.Instance;
 }
Esempio n. 5
0
 public IdentityContext(DbContextOptions options, ICurrentUnitOfWorkProvider currentUnitOfWorkProvider, IEasyNetSession session) : base(options, currentUnitOfWorkProvider, session)
 {
 }