Пример #1
0
        public List <Store> FindStoresForUserId(long userId)
        {
            List <Store> result = new List <Store>();

            List <StoreUserRelationship> relationships = AdminUsersXStores.FindByUserId(userId);

            foreach (StoreUserRelationship rel in relationships)
            {
                result.Add(Stores.FindById(rel.StoreId));
            }

            return(result);
        }
Пример #2
0
        // Stores X Users
        public bool DoesUserHaveAccessToStore(long storeId, long userId)
        {
            List <StoreUserRelationship> relationships = AdminUsersXStores.FindByStoreId(storeId);

            foreach (StoreUserRelationship r in relationships)
            {
                if (r.UserId == userId)
                {
                    return(true);
                }
            }
            return(false);
        }
Пример #3
0
        public List <UserAccount> FindAdminUsersByStoreId(long storeId)
        {
            List <UserAccount> result = new List <UserAccount>();

            List <StoreUserRelationship> relationships = AdminUsersXStores.FindByStoreId(storeId);

            foreach (StoreUserRelationship rel in relationships)
            {
                result.Add(AdminUsers.FindById(rel.UserId));
            }

            return(result);
        }
Пример #4
0
        public bool RemoveAllUsersFromStore(long storeId)
        {
            List <StoreUserRelationship> relationships = AdminUsersXStores.FindByStoreId(storeId);

            foreach (StoreUserRelationship rel in relationships)
            {
                bool temp = AdminUsersXStores.Delete(storeId, rel.UserId);
                if (temp == false)
                {
                    return(false);
                }
            }

            return(true);
        }
Пример #5
0
        public bool IsUserStoreOwner(long storeId, long userId)
        {
            List <StoreUserRelationship> relationships = AdminUsersXStores.FindByStoreId(storeId);

            foreach (StoreUserRelationship r in relationships)
            {
                if (r.UserId == userId)
                {
                    if (r.AccessMode == StoreAccessMode.Owner)
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
Пример #6
0
        //Store
        public Store FindStoreByIdForUser(long storeId, long userId)
        {
            Store result = null;

            List <StoreUserRelationship> relationships = AdminUsersXStores.FindByUserId(userId);

            foreach (StoreUserRelationship rel in relationships)
            {
                if (rel.StoreId == storeId)
                {
                    result = Stores.FindById(storeId);
                    break;
                }
            }

            return(result);
        }
Пример #7
0
        public bool AddUserToStore(long storeId, long userId, StoreAccessMode mode)
        {
            bool result = false;

            StoreUserRelationship existing = AdminUsersXStores.FindByUserIdAndStoreId(userId, storeId);

            if (existing != null)
            {
                return(true);
            }

            StoreUserRelationship rel = new StoreUserRelationship();

            rel.UserId     = userId;
            rel.StoreId    = storeId;
            rel.AccessMode = mode;

            result = AdminUsersXStores.Create(rel);

            return(result);
        }
Пример #8
0
 public bool RemoveUserFromStore(long storeId, long userId)
 {
     return(AdminUsersXStores.Delete(storeId, userId));
 }