コード例 #1
0
ファイル: UserPolicyService.cs プロジェクト: maorRoz/Sadna
        public static string[] PromoteStorePolicies(string userName, string store, StoreManagerPolicy.StoreAction[] actionsToAdd)
        {
            var userDB = UserDL.Instance;

            if (!userDB.IsUserNameExist(userName))
            {
                throw new UserException(PromoteStoreStatus.NoUserFound, "No user by the name '" + userName + " has been found for promotion!");
            }
            foreach (StoreManagerPolicy.StoreAction oldAction in Enum.GetValues(typeof(StoreManagerPolicy.StoreAction)))
            {
                userDB.DeleteUserStorePolicy(userName, new StoreManagerPolicy(store, oldAction));
            }


            if (actionsToAdd.Contains(StoreManagerPolicy.StoreAction.StoreOwner))
            {
                actionsToAdd = new [] { StoreManagerPolicy.StoreAction.StoreOwner };
            }

            var actionsThatAddedSuccessfully = new List <string>();

            foreach (StoreManagerPolicy.StoreAction action in actionsToAdd)
            {
                userDB.SaveUserStorePolicy(userName, new StoreManagerPolicy(store, action));
                actionsThatAddedSuccessfully.Add(StoreManagerPolicy.GetStoreActionString(action));
            }

            return(actionsThatAddedSuccessfully.ToArray());
        }
コード例 #2
0
 public void SaveUserStorePolicy(int userID, StoreManagerPolicy policy)
 {
     dbConnection.CheckInput(policy.Store); dbConnection.CheckInput(StoreManagerPolicy.GetStoreActionString(policy.Action));
     string[] valuesNames = { "@idParam", "@storeParam", "@actionParam" };
     object[] values      = { userID, policy.Store, StoreManagerPolicy.GetStoreActionString(policy.Action) };
     dbConnection.InsertTable("StoreManagerPolicy", "SystemID,Store,Action", valuesNames, values);
 }