Beispiel #1
0
        public virtual Boolean addStoreOwner(User session, Store s, String newOwnerUserName)
        {
            User newOwner = UserManager.getInstance().getUser(newOwnerUserName);

            if (newOwner == null || s == null || session == null)
            {
                return(false);
            }
            StoreRole sr = StoreManagement.getInstance().getStoreRole(s, newOwner);

            if (sr != null && (sr is StoreOwner))
            {
                return(false);
            }
            if (sr != null && (sr is StoreManager))
            {
                removeStoreManager(session, s, newOwnerUserName);
            }
            if (sr != null && (sr is Customer))
            {
                StoreManagement.getInstance().removeStoreRole(s.getStoreId(), newOwner.getUserName());
            }
            StoreRole owner = new StoreOwner(newOwner, s, session.userName);
            Boolean   ans   = StoreManagement.getInstance().addStoreRole(owner, s.getStoreId(), newOwner.getUserName());

            if (ans)
            {
                NotificationPublisher.getInstance().signToCategory(this, NotificationPublisher.NotificationCategories.Purchase);
                NotificationPublisher.getInstance().signToCategory(this, NotificationPublisher.NotificationCategories.RaffleSale);
                NotificationPublisher.getInstance().signToCategory(this, NotificationPublisher.NotificationCategories.Store);
            }
            return(ans);
        }
Beispiel #2
0
        private StoreManagement()
        {
            SDB     = new StoreDB(configuration.DB_MODE);
            SRDDB   = new StoreRoleDictionaryDB(configuration.DB_MODE);
            stores  = SDB.Get();
            archive = new Dictionary <int, Dictionary <String, StoreRole> >();
            LinkedList <Tuple <int, String, String, String, String> > temp = SRDDB.Get();

            foreach (Tuple <int, String, String, String, String> t in temp)
            {
                StoreRole sr = null;
                if (t.Item3 == "Manager")
                {
                    sr = new StoreManager(UserManager.getInstance().getUser(t.Item2), getStore(t.Item1), t.Item4, t.Item5);
                }
                else if (t.Item3 == "Owner")
                {
                    sr = new StoreOwner(UserManager.getInstance().getUser(t.Item2), getStore(t.Item1), t.Item4, t.Item5);
                }
                else if (t.Item3 == "Customer")
                {
                    sr = new Customer(UserManager.getInstance().getUser(t.Item2), getStore(t.Item1), "customer");
                }
                try
                {
                    archive.Add(t.Item1, new Dictionary <String, StoreRole>());
                    archive[t.Item1].Add(t.Item2, sr);
                }
                catch (Exception) {
                    archive[t.Item1].Add(t.Item2, sr);
                };
            }

            storeIndex = currIndex();
        }
Beispiel #3
0
        public virtual int createStore(String storeName, User session)
        {
            Store     newStore = StoreManagement.getInstance().addStore(storeName, session);
            StoreRole sR       = new StoreOwner(session, newStore, session.getUserName());

            StoreManagement.getInstance().addStoreRole(sR, newStore.getStoreId(), session.getUserName());
            NotificationPublisher.getInstance().signToCategory(sR, NotificationPublisher.NotificationCategories.Purchase);
            NotificationPublisher.getInstance().signToCategory(sR, NotificationPublisher.NotificationCategories.RaffleSale);
            NotificationPublisher.getInstance().signToCategory(sR, NotificationPublisher.NotificationCategories.Store);
            return(newStore.getStoreId());
        }