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); }
// 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); }
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); }
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); }
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); }
//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); }
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); }
public bool RemoveUserFromStore(long storeId, long userId) { return(AdminUsersXStores.Delete(storeId, userId)); }