Beispiel #1
0
        //This user will be store Owner
        public Tuple <bool, string> addStoreOwnership(int storeId, string appointer, bool saveCahnges = false)
        {
            Logger.logEvent(this, System.Reflection.MethodBase.GetCurrentMethod());
            if (isguest())
            {
                return(new Tuple <bool, string>(false, "Guest user cannot be store Owner\n"));
            }
            if (Store_Ownership.ContainsKey(storeId))
            {
                return(new Tuple <bool, string>(false, getUserName() + " is already store Owner\n"));
            }
            Store_Ownership.Add(storeId, appointer);

            //DB Insert//
            StoreOwnershipAppoint soa = new StoreOwnershipAppoint(appointer, this.Name, storeId);

            try
            {
                DbManager.Instance.InsertStoreOwnershipAppoint(soa, saveCahnges);
            }
            catch (Exception ex)
            {
                Logger.logError("Add Store Owner db error : " + ex.Message, this, System.Reflection.MethodBase.GetCurrentMethod());
                return(new Tuple <bool, string>(false, "Insert Store Owner Operation to DB Failed cannot proceed"));
            }
            Tuple <bool, string> ans = setPermmisions(storeId, CommonStr.StorePermissions.FullPermissions, saveCahnges);

            if (!ans.Item1)
            {
                DbManager.Instance.DeleteStoreOwnerShipAppoint(soa);
                return(new Tuple <bool, string>(false, "Insert Store Permissions Operation to DB Failed cannot proceed"));
            }
            return(new Tuple <bool, string>(true, "Insert Permissions to DB is OK"));
        }
Beispiel #2
0
        //Checks if User user appointed this current user to be owner or manager to this store
        public bool isAppointedByOwner(string user, int store_id)
        {
            Logger.logEvent(this, System.Reflection.MethodBase.GetCurrentMethod());
            string owner;

            if (!Store_Ownership.TryGetValue(store_id, out owner))
            {
                return(false);
            }
            return(owner.Equals(user));
        }
Beispiel #3
0
        public bool AppointerMasterAppointer(int storeID)
        {
            string masterA;

            if (!MasterAppointer.TryGetValue(storeID, out masterA))
            {
                return(false);
            }
            MasterAppointer.Remove(storeID);
            if (Store_Ownership.ContainsKey(storeID))
            {
                return(false);
            }
            Store_Ownership.Add(storeID, masterA);
            return(true);
        }
Beispiel #4
0
 //Remove Appoitment
 //public bool RemoveAppoitmentOwner(User owner, int id)
 //{
 //    Logger.logEvent(this, System.Reflection.MethodBase.GetCurrentMethod());
 //    return AppointedByOwner.Remove(id);
 //}
 //public bool RemoveAppoitmentManager(User owner, int id)
 //{
 //    Logger.logEvent(this, System.Reflection.MethodBase.GetCurrentMethod());
 //    return AppointedByManager.Remove(id);
 //}
 //Check if the user is Currently Store Owner
 public bool isStoreOwner(int store)
 {
     Logger.logEvent(this, System.Reflection.MethodBase.GetCurrentMethod());
     return(Store_Ownership.ContainsKey(store));
 }
Beispiel #5
0
 public bool RemoveStoreOwner(int store_id)
 {
     Logger.logEvent(this, System.Reflection.MethodBase.GetCurrentMethod());
     return(Store_Ownership.Remove(store_id));
 }