public bool makeStoreOwner(string username, Roles role, int StoreID) { Store store = GetStore(StoreID); StoreManager myStoreRoles = getStoreManagerOb(store); Member candidate = ConnectionStubTemp.getMember(username); if (candidate.isStoresManagers()) { try { candidate.GetStore(StoreID); } catch (WorkShopDbException dbExc) { throw dbExc; } catch (Exception ex) { myStoreRoles.CreateNewManager(candidate, role); } } else { myStoreRoles.CreateNewManager(candidate, role); } StoreManager candidateStoreManager = candidate.getStoreManagerOb(store); candidateStoreManager.SetStoreOwnerTrue(); ConnectionStubTemp.Update(ConnectionStubTemp.getMember(username));//shira return(true); }
public bool addManager(string username, Roles role, int StoreID) { Store store = GetStore(StoreID); StoreManager myStoreRoles = getStoreManagerOb(store); bool ret = myStoreRoles.CreateNewManager(ConnectionStubTemp.getMember(username), role); ConnectionStubTemp.Update(ConnectionStubTemp.getMember(username)); return(ret); }
/************************/ /*** This function is the function that create Store Owner - STORE USE THIS IN THE CONSTRUCTOR ***/ public void addStore(Store store) { Roles storeOwner = new Roles(true, true, true, true, true, true, true, true, true); StoreManager storeOwnerManager = new StoreManager(store, storeOwner); storeOwnerManager.SetStoreOwnerTrue(); storeManaging.AddFirst(storeOwnerManager); ConnectionStubTemp.Update(this); Logger.Log("event", logLevel.INFO, "user: "******"created succesfully new store: " + store.id); }
//TODO : is there need for remove manager option? public bool removeManager(string username, Store store) { Logger.Log("event", logLevel.INFO, "user: "******"try to remove user: " + username); StoreManager myStoreRoles = getStoreManagerOb(store); Member memberToRemove = ConnectionStubTemp.getMember(username); bool res = myStoreRoles.removeManager(memberToRemove.getStoreManagerOb(store)); memberToRemove.RemoveStoreFromMe(memberToRemove.getStoreManagerOb(store)); ConnectionStubTemp.Update(ConnectionStubTemp.getMember(username));//shira return(res); }
/// <summary> /// /// </summary> /// <param name="username"></param> /// <param name="role"></param> /// <param name="StoreID"></param> /// <returns> the request nunmber if nessecary, else -1</returns> public int addStoreOwner(string username, Roles role, int StoreID) { Store store = GetStore(StoreID); int numberOfOwners = ConnectionStubTemp.getNumOfOwners(store); int requestId; if (numberOfOwners > 1) { requestId = ConnectionStubTemp.createOwnershipRequest(store, this, ConnectionStubTemp.getMember(username)); ConnectionStubTemp.Update(ConnectionStubTemp.getMember(username));//shira return(requestId); } else if (numberOfOwners <= 0) { throw new Exception("You dont own this store! should not happen!!"); } requestId = ConnectionStubTemp.createOwnershipRequest(store, this, ConnectionStubTemp.getMember(username)); if (ConnectionStubTemp.GetOwnershipRequest(requestId) != null) { ConnectionStubTemp.deleteOwnershipRequest(ConnectionStubTemp.GetOwnershipRequest(requestId)); } ConnectionStubTemp.Update(ConnectionStubTemp.getMember(username));//shira return(-1); }