예제 #1
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);
 }
예제 #2
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;
            }
        }