コード例 #1
0
        public AclUser GetUserInfo(string login)
        {
            if (_cachePool.HasValue <AclUser>(login))
            {
                return(_cachePool.GetValue <AclUser>(login));
            }
            var user = _databaseContext.AclUsers.Include(r => r.AclDepartments)
                       .Include(r => r.Roles)
                       .FirstOrDefault(r => !r.Deleted && r.Login.ToLower() == login.ToLower());

            _cachePool.SetValue(login, user);
            return(user);
        }
コード例 #2
0
        public Request GetRequestById(int id, bool dropCache = false)
        {
            var key = id.ToString();

            if (!dropCache && _cachePool.HasValue <Request>(key))
            {
                return(_cachePool.GetValue <Request>(key));
            }
            var request = _databaseContext.Requests.Where(r => r.IdRequest == id).
                          Include(r => r.RequestType).
                          Include(r => r.RequestUserAssoc).
                          Include(r => r.RequestUserAssoc.Select(ru => ru.RequestUserRightAssocs)).
                          Include(r => r.RequestUserAssoc.Select(ru => ru.RequestUserRightAssocs.Select(rur => rur.ResourceRight))).
                          Include(r => r.RequestUserAssoc.Select(ru => ru.RequestUser)).
                          Include(r => r.RequestStates).
                          Include(r => r.RequestStates.Select(rs => rs.RequestStateType)).
                          Include(r => r.RequestAgreements).
                          Include(r => r.RequestAgreements.Select(ra => ra.User)).
                          FirstOrDefault();

            _cachePool.SetValue(key, request);
            return(request);
        }