//STAR Retrofit III.Ch1: END

        //STAR Retrofit III.Ch2: START - Added a new validator delegate to validate the credit card expiration month
        protected void ValidExpDate(Object source, ValidatorEventArgs args)
        {
            if (CCExpYear != "" && CCExpMonth != "")
            {
                if ((System.Convert.ToInt16(CCExpYear) == System.DateTime.Now.Year))
                {
                    if ((System.Convert.ToInt16(CCExpMonth) < System.DateTime.Now.Month))
                    {
                        DateTime dt = new DateTime(1990, Convert.ToInt16(CCExpMonth), 01);
                        args.IsValid = false;
                        vldExp.MarkInvalid();
                        Validator1.MarkInvalid();
                        //.Net Mig-start-Added for displaying credit card invalid error message.
                        vldExp.ErrorMessage = vldExp.ErrorMessage + "\n" + "Invalid Month: " + dt.ToString("MMMM");
                        //  vldExp.ErrorMessage = "Please complete or correct the requested information in the field(s) highlighted in red below.<br>" + "Invalid Month: " + dt.ToString("MMMM");
                        vldExpMonth.ErrorMessage = "Invalid Month: " + dt.ToString("MMMM");
                        //.NetMig-end
                        Validator2.MarkInvalid();
                        Validator2.ErrorMessage = "";
                        Validator1.ErrorMessage = "";
                    }
                }
            }
            //Added as part of .Net migration 3.5  to display error message when a month is not selected.
            if (_ExpireMonth.SelectedItem.Text == "Select Month")
            {
                args.IsValid = false;
                vldExp.MarkInvalid();
                //MAIG - CH7 - BEGIN - Added logic to display an error message if the field is empty 11/19/2014
                vldExp.ErrorMessage = Constants.PAYMENT_CARD_EXPIRATION;
                //MAIG - CH7 - END - Added logic to display an error message if the field is empty 11/19/2014
                Validator1.ErrorMessage = "";

                Validator2.MarkInvalid();
                Validator2.ErrorMessage = "";
            }

            if (_ExpireYear.SelectedItem.Text == "Select Year")
            {
                args.IsValid = false;
                vldExp.MarkInvalid();
                //MAIG - CH8 - BEGIN - Added logic to display an error message if the field is empty 11/19/2014
                vldExp.ErrorMessage = Constants.PAYMENT_CARD_EXPIRATION;
                //MAIG - CH8 - END - Added logic to display an error message if the field is empty 11/19/2014
                //67811A0  - PCI Remediation for Payment systems START -Added to validate the Select year error in payment flow page
                Validator2.MarkInvalid();
                Validator2.ErrorMessage = "";
                //67811A0  - PCI Remediation for Payment systems END -Added to validate the Select year error in payment flow page
            }
            //.Net Mig 3.5-Changes End
        }
Ejemplo n.º 2
0
 public void PriceChecking(object source, PriceCheckEventArgs args)
 {
     Console.WriteLine($"Validation service. Product type: {args.Product.Type}\tPrice: {args.Product.Price} ");
     //var validator = args.Product.Type == 1 ? typeof(Validator1) : typeof(Validator2);
     if (args.Product.Type == 1)
     {
         var validator = new Validator1();
         Console.WriteLine(validator.Validate(args.Product.Price) ? "Price is good" : "Price is bad");
     }
     else
     {
         var validator = new Validator2();
         Console.WriteLine(validator.Validate(args.Product.Price) ? "Price is good" : "Price is bad");
     }
 }