Ejemplo n.º 1
0
 public SDKClient(AppInfoSetting setting, string serverRoot)
 {
     if (!ValidateCommon.IsValid(setting, out string errorMsg))
     {
         throw new ArgumentException(errorMsg);
     }
     Setting    = setting;
     ServerRoot = serverRoot;
 }
Ejemplo n.º 2
0
 public Customer Register(Customer customer)
 {
     Condition.WithExceptionOnFailure <InvalidParameterException>()
     .Requires(customer, "customer")
     .IsNotNull();
     if (!ValidateCommon.IsValidEmail(customer.Email))
     {
         return(null);
     }
     if (!ValidateCommon.IsValidState(customer.State))
     {
         return(null);
     }
     //customer.Id = Guid.NewGuid().ToString();
     _customerRepository.Add(customer);
     _customerRepository.Save();
     return(customer);
 }
Ejemplo n.º 3
0
        private void grvOrder_ValidateRow(object sender, ValidateRowEventArgs e)
        {
            var item = e.Row as Logic.Entities.Order;

            e.Valid = false;
            if (string.IsNullOrEmpty(item.FulllName))
            {
                e.ErrorText = "Please enter customer Name";
            }
            else if (!ValidateCommon.IsValidEmail(item.Email))
            {
                e.ErrorText = "Please enter correct email address";
            }
            else if (string.IsNullOrEmpty(item.City))
            {
                e.ErrorText = "Please enter city";
            }
            else if (string.IsNullOrEmpty(item.PostalCode))
            {
                e.ErrorText = "Please enter postal code";
            }
            else if (string.IsNullOrEmpty(item.StreetAddress))
            {
                e.ErrorText = "Please enter address";
            }
            else if (string.IsNullOrEmpty(item.State))
            {
                e.ErrorText = "Please enter state";
            }
            else if (item.State.Length > 2)
            {
                e.ErrorText = "State only has 2 characters";
            }
            else if (string.IsNullOrEmpty(item.Email))
            {
                e.ErrorText = "Please Enter Email Address";
            }
            else
            {
                e.Valid = true;
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 获得当前页面客户端的IP
        /// </summary>
        /// <returns>当前页面客户端的IP</returns>
        public static string GetIp()
        {
            var result = HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"];

            if (string.IsNullOrEmpty(result))
            {
                result = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];
            }

            if (string.IsNullOrEmpty(result))
            {
                result = HttpContext.Current.Request.UserHostAddress;
            }

            if (string.IsNullOrEmpty(result) || !ValidateCommon.IsIp(result))
            {
                return("127.0.0.1");
            }

            return(result);
        }