Exemple #1
0
        public bool AddCustomerBL(CustomerEntities cust)
        {
            if (Regex.IsMatch(cust.CustomerName, "^[a-zA-Z]$") == false)
            {
                throw new InvalidStringException("not a valid name");
            }

            if (Regex.IsMatch(cust.CustomerAddress, @"^[0-9]+\s+([a-zA-Z]+|[a-zA-Z]+\s[a-zA-Z]+)$") == false)
            {
                throw new InvalidStringException("not a valid address");
            }

            if (Regex.IsMatch(cust.CustomerMobile, @"\+?[0-9]{10}") == false)
            {
                throw new InvalidStringException("not a valid mobile");
            }

            if (Regex.IsMatch(cust.CustomerEmail, @"^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$") == false)
            {
                throw new InvalidStringException("not a valid email");
            }

            if (Regex.IsMatch(cust.CustomerPan, @"^([A - Z]{ 5}\d{ 4}[A-Z]{1})$") == false)
            {
                throw new InvalidStringException("not a valid pan ");
            }

            CustomerDAL obj = new CustomerDAL();

            return(obj.AddCustomerDAL(cust));
        }
Exemple #2
0
        public bool AddCustomerBL(CustomerEntities cust)
        {
            CustomerBL customer = new CustomerBL();

            Validate(cust);

            CustomerDAL obj = new CustomerDAL();

            return(obj.AddCustomerDAL(cust));
        }
        public static bool AddCustomerBL(Customer newCustomer)
        {
            bool customerAdded = false;

            try
            {
                if (ValidateCustomer(newCustomer))
                {
                    CustomerDAL customerDAL = new CustomerDAL();
                    customerAdded = customerDAL.AddCustomerDAL(newCustomer);
                }
            }
            catch (CustomerException)
            {
                throw;
            }
            catch (Exception)
            {
                throw;
            }

            return(customerAdded);
        }