Ejemplo n.º 1
0
        public void updateStoreRole(SubscribedUser user)
        {
            string username = user.getUsername();

            foreach (StoreRole sr in DBStore.getInstance().getAllStoreRoles(username))
            {
                user.addStoreRole(sr);
            }
        }
Ejemplo n.º 2
0
        public Store createStore(String storeName, String description, SubscribedUser sub)
        {
            if (storeName == "")
            {
                throw new IllegalNameException();
            }
            Store      store = new Store(storeName, description);
            StoreOwner owner = new StoreOwner(null, sub, store);

            store.addStoreRole(owner);
            sub.addStoreRole(owner);
            DBStore.getInstance().addStore(store);
            DBStore.getInstance().addStoreRole(owner);
            return(store);
        }
Ejemplo n.º 3
0
        public void addManager(SubscribedUser manager, Permissions permissions)
        {
            StoreRole newManager = new StoreManager(this.user, store, manager, permissions);

            DBStore.getInstance().addStoreRole(newManager);
            if (store.getStoreRole(manager) != null)
            {
                throw new RoleException("user " + manager.getUsername() +
                                        " already have a role in store " +
                                        store.getStoreName());
            }
            store.addStoreRole(newManager);
            manager.addStoreRole(newManager);
            appointedByMe.Add(newManager);
        }
Ejemplo n.º 4
0
        public void addOwner(SubscribedUser owner)
        {
            StoreRole newOwner = new StoreOwner(this.user, owner, store);

            if (store.getStoreRole(owner) != null)
            {
                throw new RoleException("user " + owner.getUsername() +
                                        " already have a role in store " +
                                        store.getStoreName());
            }
            store.addStoreRole(newOwner);
            owner.addStoreRole(newOwner);
            appointedByMe.Add(newOwner);
            DBStore.getInstance().addStoreRole(newOwner);
        }
Ejemplo n.º 5
0
        public void signContract(SubscribedUser pending)
        {
            if (DBStore.getInstance().hasContract(store.getStoreID(), pending.getUsername(), userName.getUsername()))
            {
                throw new AlreadyExistException("You have already signed a contract with " + pending.getUsername());
            }
            int approvedOwners = DBStore.getInstance().getContractNum(store.getStoreID(), pending.getUsername());

            if (approvedOwners == store.getNumberOfOwners() - 1)
            {
                StoreRole newOwner = new StoreOwner(this.userName, pending, store);
                //DBStore.getInstance().signContract(store.getStoreID(), userName.getUsername(), pending.getUsername(),true);
                //DBStore.getInstance().removePendingOwner(store.getStoreID(),pending.getUsername());
                //DBStore.getInstance().addStoreRole(newOwner);
                store.addStoreRoleFromInitOwner(newOwner);
                pending.addStoreRole(newOwner);
                appointedByMe.Add(newOwner);
                DBStore.getInstance().signAndAddOwner(store.getStoreID(), userName.getUsername(), pending.getUsername(), newOwner);
            }
            else
            {
                DBStore.getInstance().signContract(store.getStoreID(), userName.getUsername(), pending.getUsername(), false);
            }
        }