/// <summary>
        /// 删除客户
        /// </summary>
        /// <param name="customerID">客户编号</param>
        public HttpResponseMessage Delete(int customerID)
        {
            if (customerID == 0)
            {
                return new HttpResponseMessage(HttpStatusCode.BadRequest);
            }
            else
            {
                var customerFunction = new CustomerFunction();
                int error = customerFunction.DeleteCustomerByID(customerID);
                var response = GetResponse.UserResponse(error);

                return response;
            }
        }
        /// <summary>
        /// 删除客户
        /// </summary>
        /// <param name="entity">客户视图</param>
        public HttpResponseMessage Delete([FromBody]Customer entity)
        {
            if (entity == null)
            {
                return new HttpResponseMessage(HttpStatusCode.BadRequest);
            }
            else
            {
                var customerFunction = new CustomerFunction();
                int error = customerFunction.DeleteCustomer(entity);
                var response = GetResponse.UserResponse(error);

                return response;
            }
        }
        /// <summary>
        /// 查询客户或用户登录
        /// </summary>
        /// <returns>客户视图,总页数</returns>
        public HttpResponseMessage Get()
        {
            int totalPage = 0;
            List<CustomerViewResult> result = new List<CustomerViewResult>();

            var queryString = Request.GetQueryNameValuePairs();

            if (queryString.Any(q => q.Key.ToLower() == "password"))
            {
                string customerName = queryString.FirstOrDefault(q => q.Key.ToLower() == "customername").Value;
                string password = queryString.FirstOrDefault(q => q.Key.ToLower() == "password").Value;

                Customer entity = new Customer() { CustomerName = customerName, Password = password };
                CustomerViewResult logonCustomer = new CustomerViewResult();

                var customerFunction = new CustomerFunction();
                int error = customerFunction.CheckCustomer(entity, out logonCustomer);

                if (error == 0)
                {
                    return Request.CreateResponse(HttpStatusCode.OK, logonCustomer);
                }
                else
                {
                    return GetResponse.UserResponse(error);
                }
            }
            else
            {
                var queryConditions = new CustomerQueryConditions();
                queryConditions.GetValues(queryString);

                CustomerFunction customerFunction = new CustomerFunction();
                customerFunction.QueryCustomers(queryConditions, out result, out totalPage);

                List<object> objectResult = new List<object>() { result, new { totalPage = totalPage } };
                return Request.CreateResponse(HttpStatusCode.OK, objectResult);
            }
        }
        /// <summary>
        /// 新增客户
        /// </summary>
        /// <param name="entity">客户视图</param>
        public HttpResponseMessage Post([FromBody]Customer entity)
        {
            var result = new CustomerViewResult();
            var response = new HttpResponseMessage();

            if (entity == null)
            {
                return new HttpResponseMessage(HttpStatusCode.BadRequest);
            }
            else
            {
                var customerFunction = new CustomerFunction();
                int error = customerFunction.AddCustomer(entity, out result);
                if (error == 0)
                {
                    response = Request.CreateResponse(HttpStatusCode.OK, result);
                }
                else
                {
                    response = GetResponse.UserResponse(error);
                }

                return response;
            }
        }
        /// <summary>
        /// 查询客户
        /// </summary>
        /// <param name="customerID">客户编号</param>
        /// <returns>客户视图</returns>
        public CustomerViewResult Get(int customerID)
        {
            int totalPage = 0;
            List<CustomerViewResult> result = new List<CustomerViewResult>();

            var queryConditions = new CustomerQueryConditions() { CustomerID = customerID };

            CustomerFunction customerFunction = new CustomerFunction();
            customerFunction.QueryCustomers(queryConditions, out result, out totalPage);

            return result.FirstOrDefault();
        }