コード例 #1
0
        public IActionResult GetCustomer(HttpRequestMessage request, [FromQuery] string Id)
        {
            CustomerModel           customer            = new CustomerModel();
            CustomerBusinessService userBusinessService = new CustomerBusinessService(_customerDataService);

            userBusinessService.GetCustomer(Guid.Parse(Id), out customer);
            return(new ObjectResult(customer));
        }
コード例 #2
0
        public HttpResponseMessage GetCustomer(HttpRequestMessage request, [FromBody] CustomerInformation customerInformation)
        {
            TransactionalInformation transaction = new TransactionalInformation();

            int customerID = customerInformation.CustomerID;

            CustomerBusinessService customerBusinessService = new CustomerBusinessService(_customerDataService);

            customerInformation = customerBusinessService.GetCustomer(customerID, out transaction);
            if (transaction.ReturnStatus == false)
            {
                var badResponse = Request.CreateResponse <TransactionalInformation>(HttpStatusCode.BadRequest, transaction);
                return(badResponse);
            }

            customerInformation.ReturnStatus = transaction.ReturnStatus;

            var response = Request.CreateResponse <CustomerInformation>(HttpStatusCode.OK, customerInformation);

            return(response);
        }
コード例 #3
0
        public HttpResponseMessage GetCustomer(HttpRequestMessage request, [FromBody] CustomerViewModel customerViewModel)
        {
            TransactionalInformation transaction;

            int customerID = customerViewModel.CustomerID;

            CustomerBusinessService customerBusinessService = new CustomerBusinessService(_customerDataService);
            Customer customer = customerBusinessService.GetCustomer(customerID, out transaction);

            if (transaction.ReturnStatus == false)
            {
                customerViewModel.ReturnStatus     = false;
                customerViewModel.ReturnMessage    = transaction.ReturnMessage;
                customerViewModel.ValidationErrors = transaction.ValidationErrors;

                var responseError = Request.CreateResponse <CustomerViewModel>(HttpStatusCode.BadRequest, customerViewModel);
                return(responseError);
            }

            customerViewModel.CustomerID   = customer.CustomerID;
            customerViewModel.CompanyName  = customer.CompanyName;
            customerViewModel.ContactName  = customer.ContactName;
            customerViewModel.ContactTitle = customer.ContactTitle;
            customerViewModel.CustomerCode = customer.CustomerCode;
            customerViewModel.Address      = customer.Address;
            customerViewModel.City         = customer.City;
            customerViewModel.Region       = customer.Region;
            customerViewModel.PostalCode   = customer.PostalCode;
            customerViewModel.Country      = customer.Country;
            customerViewModel.PhoneNumber  = customer.PhoneNumber;
            customerViewModel.MobileNumber = customer.MobileNumber;

            customerViewModel.ReturnStatus  = true;
            customerViewModel.ReturnMessage = transaction.ReturnMessage;

            var response = Request.CreateResponse <CustomerViewModel>(HttpStatusCode.OK, customerViewModel);

            return(response);
        }