Example #1
0
        public questStatus Read(UserId userId, out UserPrivilegeList userPrivilegeList)
        {
            // Initialize
            questStatus status = null;

            userPrivilegeList = null;


            // Get user
            User user = null;

            status = _dbUsersMgr.Read(userId, out user);
            if (!questStatusDef.IsSuccess(status))
            {
                return(status);
            }

            // Get user privileges
            using (FMSEntities dbContext = new FMSEntities())
            {
                List <Quest.Services.Dbio.FMS.UserPrivileges> _userPrivilegeList = null;
                status = read(dbContext, userId, out _userPrivilegeList);
                if (!questStatusDef.IsSuccess(status))
                {
                    return(status);
                }
                userPrivilegeList      = new UserPrivilegeList();
                userPrivilegeList.User = user;
                foreach (Quest.Services.Dbio.FMS.UserPrivileges _userPrivilege in _userPrivilegeList)
                {
                    // Get privilege
                    PrivilegeId privilegeId = new PrivilegeId(_userPrivilege.PrivilegeId);
                    Privilege   privilege   = null;
                    status = _dbPrivilegesMgr.Read(privilegeId, out privilege);
                    if (!questStatusDef.IsSuccess(status))
                    {
                        return(status);
                    }
                    userPrivilegeList.PrivilegeList.Add(privilege);
                }
            }
            return(new questStatus(Severity.Success));
        }
        public questStatus Read(GroupId groupId, out GroupUserList groupUserList)
        {
            // Initialize
            questStatus status = null;

            groupUserList = null;


            // Get group
            Group group = null;

            status = _dbGroupsMgr.Read(groupId, out group);
            if (!questStatusDef.IsSuccess(status))
            {
                return(status);
            }

            // Get group users
            using (FMSEntities dbContext = new FMSEntities())
            {
                List <Quest.Services.Dbio.FMS.GroupUsers> _groupUserList = null;
                status = read(dbContext, groupId, out _groupUserList);
                if (!questStatusDef.IsSuccess(status))
                {
                    return(status);
                }
                groupUserList       = new GroupUserList();
                groupUserList.Group = group;
                foreach (Quest.Services.Dbio.FMS.GroupUsers _groupUser in _groupUserList)
                {
                    // Get user
                    UserId userId = new UserId(_groupUser.UserId);
                    User   user   = null;
                    status = _dbUsersMgr.Read(userId, out user);
                    if (!questStatusDef.IsSuccess(status))
                    {
                        return(status);
                    }
                    groupUserList.UserList.Add(user);
                }
            }
            return(new questStatus(Severity.Success));
        }