// realize the 'handleDonate() method'
        public override string handleDonate(Donation donate)
        {
            string procResult = "";

            if (donate.type == DonateType.人民團體)
            {
                if (donate.money <= 500000)
                {
                    procResult = "Handle Donation by #" + this.GetType().Name + "\n";
                }
                else
                    throw new DonateExceedException("人民團體捐贈政治獻金不得超過法定限額:五十萬");
            }
            else
            {
                // 如果有下一個鏈結的 Hanlder,交給它處理
                if (this.Successor != null)
                    procResult = Successor.handleDonate(donate);
                else
                {
                    throw new NullHanderException("沒有 Handler 處理這個 Donation !\n" +
                        "原因:" + donate.ext_info);
                }
            }

            return procResult;
        }
        public ActionResult handleDonate(string TxtName, string SelDonateType, string TxtDonateMoney, string TxtExtInfo)
        {
            procDonateControl control = new procDonateControl();    // new a domain controller
            Donation donate = new Donation();                       // new a Donation DTO Class.
            DonateType dtype;

            switch (SelDonateType)
            { 
                case ("個人") :
                    dtype = DonateType.個人;
                    break;
                case ("營利事業"):
                    dtype = DonateType.營利事業;
                    break;
                case ("人民團體"):
                    dtype = DonateType.人民團體;
                    break;
                default :
                    dtype = DonateType.UNKNOWN;
                    break;
            }

            // put the form's values into donate instance.
            donate.name = TxtName;
            donate.type = dtype;
            donate.money = Convert.ToInt32(TxtDonateMoney);
            donate.ext_info = TxtExtInfo;

            // get the process result.
            ViewData["ProcssResult"] = control.procDonation(donate);

            return View("Index");
        }
        public string procDonation(Donation donate)
        { 
            string procResult = "";
            DonateHandler handler;
            
            handler = this.SetupHandlers();         // Setup all the donation handlers and return the first hander.
            try
            {
                procResult = handler.handleDonate(donate);
            }
            catch (DonateExceedException de)
            {
                procResult = de.Message;
            }
            catch (NullHanderException ne)
            {
                procResult = ne.Message;
            }

            return procResult;
        }
 public abstract string handleDonate(Donation donate);       // abstract method, 關於捐贈的邏輯處理,由 extend 的 Handler 實現