Esempio n. 1
0
        public void makeOwner()
        {
            Roles roles = ConnectionStubTemp.getMember(initiate).getStoreManagerRoles(store.id);

            ConnectionStubTemp.getMember(initiate).makeStoreOwner(candidate.username, roles, store.id);
            ConnectionStubTemp.deleteOwnershipRequest(this);
        }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
        //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);
        }
Esempio n. 5
0
 public void sendRequestsToOwners(Store store, int creatorId, string candidateName, int requestId)
 {
     lock (OwnersLock)
     {
         foreach (Decision d in owners)
         {
             Member currMember = ConnectionStubTemp.getMember(d.username);
             if (currMember.id != creatorId && currMember.username != candidateName)
             {
                 currMember.addMessage("Do you agree adding " + candidateName + " as a co - owner to the store " + store.name + "?", Notification.NotificationType.CREATE_OWNER, requestId);
             }
         }
     }
 }
Esempio n. 6
0
        public bool RemoveUser(string userName)
        {
            Member member;

            try
            {
                member = ConnectionStubTemp.getMember(userName);
            }
            catch (WorkShopDbException dbExc)
            {
                throw dbExc;
            }
            catch (Exception ex)
            {
                Logger.Log("event", logLevel.INFO, "Admin fail removed user: "******" user doen't exist");
                throw new Exception(ex.ToString());
            }
            if (member.isStoresManagers())
            {
                int          count = member.storeManaging.Count - 1;
                StoreManager st    = member.storeManaging.ElementAt(count);
                try
                {
                    for (; count > -1; count--, st = member.storeManaging.ElementAt(count))
                    {
                        if (ConnectionStubTemp.getAllOwnersCount(st.store) == 1 /*st.GetFather() == null*/)///change to super father
                        {
                            Store store = st.GetStore();
                            WorkShop.closeStore(store.id, member);
                        }
                        else
                        {
                            StoreManager father = st.GetFather();
                            father.removeManager(st);
                        }
                    }
                } catch (Exception ex)
                {
                }
                ConnectionStubTemp.removeMember(member);
                Logger.Log("event", logLevel.INFO, "Admin succesfully removed user: "******"event", logLevel.INFO, "Admin succesfully removed user: " + userName);
                ConnectionStubTemp.removeMember(member);
                return(ConnectionStubTemp.removeUser(userName, this));
            }
        }
Esempio n. 7
0
        /*** SERVICE LAYER FUNCTIONS***/

        public Member loginMember(string username, string password)
        {
            //TODO:: load shopping basket


            int ID = ConnectionStubTemp.identifyUser(username, password);

            if (ID == -1)
            {
                //don't log password!
                Logger.Log("event", logLevel.INFO, "user: "******"tried to log in and failed");
                throw new Exception("incorrect username or password");
            }
            Logger.Log("event", logLevel.INFO, "user: "******"log in and succses");
            return(ConnectionStubTemp.getMember(ID));
        }
Esempio n. 8
0
        /// <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);
        }
Esempio n. 9
0
        public bool addManager(string username, Roles role, Store store)
        {
            StoreManager myStoreRoles = getStoreManagerOb(store);

            return(myStoreRoles.CreateNewManager(ConnectionStubTemp.getMember(username), role));
        }