public HttpResponseMessage GetCustomer([FromUri] Guid customerID)
        {

            CustomersApiModel customersWebApiModel = new CustomersApiModel();
            TransactionalInformation transaction = new TransactionalInformation();
            CustomersBusinessService customersBusinessService;         

            customersWebApiModel = new CustomersApiModel();

            customersBusinessService = new CustomersBusinessService(customersDataService);

            Customer customer = customersBusinessService.GetCustomer(customerID, out transaction);

            customersWebApiModel.Customer = customer;
            customersWebApiModel.IsAuthenicated = true;
            customersWebApiModel.ReturnStatus = transaction.ReturnStatus;
            customersWebApiModel.ReturnMessage = transaction.ReturnMessage;          

            if (transaction.ReturnStatus == true)
            {
                var response = Request.CreateResponse<CustomersApiModel>(HttpStatusCode.OK, customersWebApiModel);
                return response;
            }

            var badResponse = Request.CreateResponse<CustomersApiModel>(HttpStatusCode.BadRequest, customersWebApiModel);
            return badResponse;


        }
        public HttpResponseMessage InitializeOrder(HttpRequestMessage request, [FromBody] OrderDTO orderDTO)
        {
            OrdersApiModel ordersWebApiModel = new OrdersApiModel();
            TransactionalInformation transaction = new TransactionalInformation();
            OrdersBusinessService ordersBusinessService;
            CustomersBusinessService customersBusinessService;
            ordersWebApiModel.IsAuthenicated = true;

            customersBusinessService = new CustomersBusinessService(customersDataService);
            Customer customer = customersBusinessService.GetCustomer(orderDTO.CustomerID, out transaction);
            if (transaction.ReturnStatus == false)
            {
                ordersWebApiModel.ReturnMessage = transaction.ReturnMessage;
                ordersWebApiModel.ReturnStatus = transaction.ReturnStatus;
                ordersWebApiModel.ValidationErrors = transaction.ValidationErrors;
                var badResponse = Request.CreateResponse<OrdersApiModel>(HttpStatusCode.BadRequest, ordersWebApiModel);
                return badResponse;
            }

            ordersBusinessService = new OrdersBusinessService(ordersDataService);
            List<Shipper> shippers = ordersBusinessService.GetShippers(out transaction);
            if (transaction.ReturnStatus == false)
            {
                ordersWebApiModel.ReturnMessage = transaction.ReturnMessage;
                ordersWebApiModel.ReturnStatus = transaction.ReturnStatus;
                ordersWebApiModel.ValidationErrors = transaction.ValidationErrors;
                var badResponse = Request.CreateResponse<OrdersApiModel>(HttpStatusCode.BadRequest, ordersWebApiModel);
                return badResponse;
            }
            
            ordersWebApiModel.ReturnStatus = transaction.ReturnStatus;
            ordersWebApiModel.ReturnMessage = transaction.ReturnMessage;
            ordersWebApiModel.Customer = customer;
            ordersWebApiModel.Shippers = shippers;

            var response = Request.CreateResponse<OrdersApiModel>(HttpStatusCode.OK, ordersWebApiModel);
            return response;


        }
        public HttpResponseMessage CustomerInquiry([FromUri] CustomerInquiryDTO customerInquiryDTO)
        {

            if (customerInquiryDTO.CustomerCode == null) customerInquiryDTO.CustomerCode = string.Empty;
            if (customerInquiryDTO.CompanyName == null) customerInquiryDTO.CompanyName = string.Empty;
            if (customerInquiryDTO.SortDirection == null) customerInquiryDTO.SortDirection = string.Empty;
            if (customerInquiryDTO.SortExpression == null) customerInquiryDTO.SortExpression = string.Empty;

            CustomersApiModel customersWebApiModel = new CustomersApiModel();
            TransactionalInformation transaction = new TransactionalInformation();
            CustomersBusinessService customersBusinessService;

            customersWebApiModel = new CustomersApiModel();

            DataGridPagingInformation paging = new DataGridPagingInformation();
            paging.CurrentPageNumber = customerInquiryDTO.CurrentPageNumber;
            paging.PageSize = customerInquiryDTO.PageSize;
            paging.SortExpression = customerInquiryDTO.SortExpression;
            paging.SortDirection = customerInquiryDTO.SortDirection;

            if (paging.SortDirection == "") paging.SortDirection = "ASC";
            if (paging.SortExpression == "") paging.SortExpression = "CompanyName";

            customersBusinessService = new CustomersBusinessService(customersDataService);

            List<Customer> customers = customersBusinessService.CustomerInquiry(customerInquiryDTO.CustomerCode, customerInquiryDTO.CompanyName, paging, out transaction);

            customersWebApiModel.Customers = customers;
            customersWebApiModel.IsAuthenicated = true;
            customersWebApiModel.ReturnStatus = transaction.ReturnStatus;
            customersWebApiModel.ReturnMessage = transaction.ReturnMessage;
            customersWebApiModel.TotalPages = transaction.TotalPages;
            customersWebApiModel.TotalRows = transaction.TotalRows;
            customersWebApiModel.PageSize = paging.PageSize;
            customersWebApiModel.IsAuthenicated = true;

            if (transaction.ReturnStatus == true)
            {
                var response = Request.CreateResponse<CustomersApiModel>(HttpStatusCode.OK, customersWebApiModel);
                return response;
            }

            var badResponse = Request.CreateResponse<CustomersApiModel>(HttpStatusCode.BadRequest, customersWebApiModel);
            return badResponse;


        }
        public HttpResponseMessage ImportCustomers(HttpRequestMessage request)
        {

            CustomersApiModel customersWebApiModel = new CustomersApiModel();
            TransactionalInformation transaction = new TransactionalInformation();
            CustomersBusinessService customersBusinessService;
            customersWebApiModel.IsAuthenicated = true;
          
            customersBusinessService = new CustomersBusinessService(customersDataService);
            customersBusinessService.ImportCustomers(out transaction);         

            if (transaction.ReturnStatus == false)
            {
                customersWebApiModel.ReturnMessage = transaction.ReturnMessage;
                customersWebApiModel.ReturnStatus = transaction.ReturnStatus;
                customersWebApiModel.ValidationErrors = transaction.ValidationErrors;
                var badResponse = Request.CreateResponse<CustomersApiModel>(HttpStatusCode.BadRequest, customersWebApiModel);
                return badResponse;
            }

            customersWebApiModel.ReturnStatus = transaction.ReturnStatus;
            customersWebApiModel.ReturnMessage = transaction.ReturnMessage;                  
    
            var response = Request.CreateResponse<CustomersApiModel>(HttpStatusCode.OK, customersWebApiModel);
            return response;


        }
        public HttpResponseMessage UpdateCustomer(HttpRequestMessage request, [FromBody] CustomerDTO customerDTO)
        {
            CustomersApiModel customersWebApiModel = new CustomersApiModel();
            TransactionalInformation transaction = new TransactionalInformation();
            CustomersBusinessService customersBusinessService;
            customersWebApiModel.IsAuthenicated = true;
              
            if (customerDTO.CustomerCode == null) customerDTO.CustomerCode = string.Empty;
            if (customerDTO.CompanyName == null) customerDTO.CompanyName = string.Empty;
            if (customerDTO.Address == null) customerDTO.Address = string.Empty;
            if (customerDTO.City == null) customerDTO.City = string.Empty;
            if (customerDTO.Region == null) customerDTO.Region = string.Empty;
            if (customerDTO.PostalCode == null) customerDTO.PostalCode = string.Empty;
            if (customerDTO.Country == null) customerDTO.Country = string.Empty;
            if (customerDTO.PhoneNumber == null) customerDTO.PhoneNumber = string.Empty;
            if (customerDTO.WebSiteUrl == null) customerDTO.WebSiteUrl = string.Empty;

            customersBusinessService = new CustomersBusinessService(customersDataService);

            Customer customer = customersBusinessService.UpdateCustomer(
                customerDTO.CustomerID,
                customerDTO.CustomerCode,
                customerDTO.CompanyName,
                customerDTO.Address,
                customerDTO.City,
                customerDTO.Region,
                customerDTO.PostalCode,
                customerDTO.Country,
                customerDTO.PhoneNumber,
                customerDTO.WebSiteUrl,
                out transaction);

            if (transaction.ReturnStatus == false)
            {
                customersWebApiModel.ReturnMessage = transaction.ReturnMessage;
                customersWebApiModel.ReturnStatus = transaction.ReturnStatus;
                customersWebApiModel.ValidationErrors = transaction.ValidationErrors;
                var badResponse = Request.CreateResponse<CustomersApiModel>(HttpStatusCode.BadRequest, customersWebApiModel);
                return badResponse;
            }
           
            customersWebApiModel.ReturnStatus = transaction.ReturnStatus;
            customersWebApiModel.ReturnMessage = transaction.ReturnMessage;
            customersWebApiModel.Customer = customer;

            var response = Request.CreateResponse<CustomersApiModel>(HttpStatusCode.OK, customersWebApiModel);
            return response;

        }