Exemplo n.º 1
0
        /// <summary>
        /// Adds the pay element.
        /// </summary>
        /// <param name="handlerName">Name of the handler.</param>
        /// <param name="element">The element.</param>
        static void AddPayElement(string handlerName, PayMethodElement element)
        {
            PaymentHandlerElement handler = GetPayHandlerConfigElement(handlerName);

            RemovePayElement(handler, element);
            handler.HandlerPayMethods.Add(element);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Removes the specified element.
 /// </summary>
 /// <param name="element">The element.</param>
 public void Remove(PaymentHandlerElement element)
 {
     if (BaseIndexOf(element) >= 0)
     {
         BaseRemove(element.HandlerName);
     }
 }
Exemplo n.º 3
0
        /// <summary>
        /// Adds the pay element.
        /// </summary>
        /// <param name="handlerName">Name of the handler.</param>
        /// <param name="element">The element.</param>
        public static void RemovePayElement(string handlerName, string elementName)
        {
            PaymentHandlerElement handler = GetPayHandlerConfigElement(handlerName);
            PayMethodElement      element = HandlersPayMethod(handler.HandlerName).DefaultIfEmpty(null).FirstOrDefault(h => h.MethodName == elementName);

            if (element != null)
            {
                RemovePayElement(handler, element);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Gets the handler name by pay method.
        /// </summary>
        /// <param name="payMethod">The pay method.</param>
        /// <returns></returns>
        public static string GetHandlerNameByPayMethod(string payMethod)
        {
            PaymentHandlerElement returnValue = GetHandlerByPayMethod(payMethod);

            if (returnValue == null)
            {
                return(null);
            }
            return(returnValue.HandlerName);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Adds the pay element.
        /// </summary>
        /// <param name="handlerName">Name of the handler.</param>
        /// <param name="methodName">Name of the method.</param>
        /// <param name="code">The code.</param>
        /// <param name="description">The descrption.</param>
        public static void AddPayElement(string handlerName, string methodName, string code, string description)
        {
            PaymentHandlerElement handler = GetPayHandlerConfigElement(handlerName);

            if (!PaymethodExists(methodName))
            {
                PayMethodElement element = new PayMethodElement()
                {
                    MethodName = methodName, Code = code, Description = description
                };
                AddPayElement(handlerName, element);
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Gets the pay handler by pay method.
        /// </summary>
        /// <param name="payMethod">The pay method.</param>
        /// <returns></returns>
        static PaymentHandlerElement GetHandlerByPayMethod(string payMethod)
        {
            PaymentHandlerElement returnValue = null;

            foreach (PaymentHandlerElement h in _handlers.Values.ToList())
            {
                if (HandlersPayMethod(h.HandlerName).Exists(m => m.MethodName == payMethod))
                {
                    returnValue = h;
                    break;
                }
            }
            return(returnValue);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Modifies the pay element.
        /// </summary>
        /// <param name="currentHandlerName">Name of the current handler.</param>
        /// <param name="currentMethodName">Name of the current method.</param>
        /// <param name="newHandlerName">New name of the handler.</param>
        /// <param name="newMethodName">New name of the method.</param>
        /// <param name="code">The code.</param>
        /// <param name="description">The description.</param>
        public static void ModifyPayElement(string currentHandlerName, string currentMethodName, string newHandlerName, string newMethodName, string code, string description)
        {
            PaymentHandlerElement currentHandler = null;

            bool changeMethodName = newMethodName != currentMethodName;
            bool changeHandler    = currentHandlerName != newHandlerName;

            if (_handlers.ContainsKey(currentHandlerName))
            {
                currentHandler = _handlers[currentHandlerName];
            }
            if (currentHandler == null)
            {
                currentHandler = _handlers[newHandlerName];
                changeHandler  = true;
            }
            PaymentHandlerElement newHandler = _handlers[newHandlerName];

            if (changeHandler)
            {// chaging the handler
                PayMethodElement element = HandlersPayMethod(currentHandler.HandlerName).DefaultIfEmpty(null).FirstOrDefault(h => h.MethodName == currentMethodName);
                if (element != null)
                {
                    RemovePayElement(currentHandler, element);
                }
                AddPayElement(newHandlerName, newMethodName, code, description);
            }
            else
            {
                //we are not changing the handler
                PayMethodElement element = HandlersPayMethod(newHandler.HandlerName).DefaultIfEmpty(null).FirstOrDefault(h => h.MethodName == currentMethodName);
                if (element != null)
                {
                    //current paymethod exists for the handler
                    if (changeMethodName)
                    {
                        element.MethodName = newMethodName;
                    }
                    element.Code        = code;
                    element.Description = description;
                }
            }
        }
Exemplo n.º 8
0
 /// <summary>
 /// Removes the pay element.
 /// </summary>
 /// <param name="handler">The handler.</param>
 /// <param name="element">The element.</param>
 static void RemovePayElement(PaymentHandlerElement handler, PayMethodElement element)
 {
     handler.HandlerPayMethods.Remove(element);
 }
Exemplo n.º 9
0
        /// <summary>
        /// Handlers the name of the control.
        /// </summary>
        /// <param name="handlerName">Name of the handler.</param>
        /// <returns></returns>
        public static string HandlerControlName(string handlerName)
        {
            PaymentHandlerElement handler = _handlers[handlerName];

            return(handler.ControlName);
        }
Exemplo n.º 10
0
 /// <summary>
 /// Collection type setting
 /// </summary>
 //public override ConfigurationElementCollectionType CollectionType
 //{
 //    get
 //    {
 //        return ConfigurationElementCollectionType.AddRemoveClearMap;
 //    }
 //}
 /// <summary>
 /// Indexofs the specified element.
 /// </summary>
 /// <param name="element">The element.</param>
 /// <returns></returns>
 public int indexof(PaymentHandlerElement element)
 {
     return(BaseIndexOf(element));
 }
Exemplo n.º 11
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PaymentHandlerCollection"/> class.
 /// </summary>
 //public PaymentHandlerCollection()
 //{
 //    PaymentHandlerElement myElement = (PaymentHandlerElement)CreateNewElement();
 //   // Add(myElement);
 //}
 /// <summary>
 /// Adds the specified custom element.
 /// </summary>
 /// <param name="customElement">The custom element.</param>
 protected void Add(PaymentHandlerElement customElement)
 {
     BaseAdd(customElement);
 }