Exemplo n.º 1
0
        public void UpdateCustomerIntegrationTest()
        {
            string returnMessage;

            TransactionalInformation transaction;

            CustomerApplicationService customerApplicationService = new CustomerApplicationService(customerDataService);

            DataGridPagingInformation paging = new DataGridPagingInformation();

            paging.CurrentPageNumber = 1;
            paging.PageSize          = 15;
            paging.SortExpression    = "LastName";
            paging.SortDirection     = "ASC";

            List <CustomerInquiry> customers = customerApplicationService.CustomerInquiry("", "", paging, out transaction);

            var  customerInformation = (from c in customers select c).First();
            Guid customerID          = customerInformation.CustomerID;

            Customer customer = customerApplicationService.GetCustomerByCustomerID(customerID, out transaction);

            customerApplicationService.UpdateCustomer(customer, out transaction);
            returnMessage = Utilities.GetReturnMessage(transaction.ReturnMessage);

            Assert.AreEqual(true, transaction.ReturnStatus, returnMessage);
        }
        public HttpResponseMessage GetCustomerMaintenanceInformation(HttpRequestMessage request, Guid customerID)
        {
            TransactionalInformation customerTransaction;
            TransactionalInformation paymentTransaction;

            CustomerMaintenanceViewModel customerMaintenanceViewModel = new CustomerMaintenanceViewModel();

            CustomerApplicationService customerApplicationService = new CustomerApplicationService(customerDataService);

            if (customerID != Guid.Empty)
            {
                Customer customer = customerApplicationService.GetCustomerByCustomerID(customerID, out customerTransaction);
                customerMaintenanceViewModel.Customer      = customer;
                customerMaintenanceViewModel.ReturnStatus  = customerTransaction.ReturnStatus;
                customerMaintenanceViewModel.ReturnMessage = customerTransaction.ReturnMessage;
            }

            List <PaymentType> paymentTypes = customerApplicationService.GetPaymentTypes(out paymentTransaction);

            customerMaintenanceViewModel.PaymentTypes = paymentTypes;
            if (paymentTransaction.ReturnStatus == false)
            {
                customerMaintenanceViewModel.ReturnStatus  = paymentTransaction.ReturnStatus;
                customerMaintenanceViewModel.ReturnMessage = paymentTransaction.ReturnMessage;
            }

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

            var badResponse = Request.CreateResponse <CustomerMaintenanceViewModel>(HttpStatusCode.BadRequest, customerMaintenanceViewModel);

            return(badResponse);
        }