コード例 #1
0
        public virtual async Task <bool> DeviceExist(T model, IAuthUser <int, TRole, T> user)
        {
            try
            {
                var device = _cache?.FindFirst(m => m.DeviceId == model.DeviceId && m.UserId == user.Id);
                if (device != null)
                {
                    return(true);
                }
                device = await _db.FirstOrDefaultAsync(m => m.DeviceId == model.DeviceId && m.UserId == user.Id);

                if (device != null)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception ext)
            {
                throw new Exception(ext.Message, ext);
            }
        }
コード例 #2
0
        public T GetFirst(Expression <Func <T, bool> > expression, [CallerLineNumber] int lineNumber = 0, [CallerMemberName] string caller = null)
        {
            T result = null;

            result = _cache?.FindFirst(expression);
            if (result != null)
            {
                return(result);
            }
            return(_session.Query <T>().FirstOrDefaultAsync(expression).Result);
        }
コード例 #3
0
 public virtual async Task <T> GetByRefresh(string refreshToken)
 {
     try
     {
         return(_cache.FindFirst(m => m.RefreshToken == refreshToken) ?? await _db.FirstOrDefaultAsync(m => m.RefreshToken == refreshToken));
     }
     catch (Exception ext)
     {
         throw new Exception(ext.Message, ext);
     }
 }
コード例 #4
0
        public virtual T GetFirst(Expression <Func <T, bool> > selector, [CallerLineNumber] int lineNumber = 0, [CallerMemberName] string caller = null)
        {
            var result = _cache?.FindFirst(selector);

            if (result != null)
            {
                return(result);
            }
            result = _dbSet.FirstOrDefault(selector);
            return(result);
        }