public bool AddCustomer(Customer customer)
        {
            customer.Password = customer.Password.HashSha256();

            try
            {
                if (CustomerAccessor.InsertCustomer(customer))
                {
                    return(true);
                }
            }
            catch (Exception)
            {
                throw new ApplicationException("User could not be added");
            }

            return(false);
        }
        /// <summary>
        /// Inserts the new customer.
        /// </summary>
        /// <param name="firstName">The first name.</param>
        /// <param name="lastName">The last name.</param>
        /// <param name="emailID">The email identifier.</param>
        /// <param name="phoneNO1">The phone n o1.</param>
        /// <param name="phoneNO2">The phone n o2.</param>
        /// <param name="address1">The address1.</param>
        /// <param name="address2">The address2.</param>
        /// <param name="postalCode">The postal code.</param>
        /// <param name="city">The city.</param>
        /// <param name="state">The state.</param>
        /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
        public bool InsertNewCustomer(string firstName,
                                      string lastName,
                                      string emailID,
                                      string phoneNO1,
                                      string phoneNO2,
                                      string address1,
                                      string address2,
                                      string postalCode,
                                      string city,
                                      string state)
        {
            try
            {
                var cstmer = new Customer()
                {
                    FirstName  = firstName,
                    LastName   = lastName,
                    EmailID    = emailID,
                    PhoneNo1   = phoneNO1,
                    PhoneNo2   = phoneNO2,
                    Address1   = address1,
                    Address2   = address2,
                    PostalCode = postalCode,
                    City       = city,
                    State      = state
                };
                if (CustomerAccessor.InsertCustomer(cstmer) >= 1)
                {
                    return(true);
                }
            }
            catch (Exception)
            {
                throw;
            }

            return(false);
        }
Exemple #3
0
        public Response <Customer> OperateCustomer(AddCustomerRequest request)
        {
            Response <Customer> response = new Response <Customer>();

            if (request == null || request.Customer == null)
            {
                ArgumentNullException ex = new ArgumentNullException("OperateCustomer request");
                LogError(ex);
                response.ErrorCode = ErrorCode.Argument;
                response.Exception = ex;
                return(response);
            }
            try
            {
                CustomerAccessor CustomerAccessor = new CustomerAccessor();
                response.Result = CustomerAccessor.InsertCustomer(request.Customer);
                if (response.Result.ID > 0)
                {
                    response.IsSuccess = true;
                }
                else
                {
                    response.IsSuccess = false;
                    response.ErrorCode = ErrorCode.Technical;
                }
            }
            catch (Exception ex)
            {
                LogError(ex);
                response.IsSuccess = false;
                response.Exception = ex;
                response.ErrorCode = ErrorCode.Technical;
                throw;
            }
            return(response);
        }