Example #1
0
        public void CreateCustomerIntegrationTest()
        {
            string returnMessage;

            TransactionalInformation transaction;

            CustomerApplicationService customerApplicationService = new CustomerApplicationService(customerDataService);
            List <PaymentType>         paymentTypes = customerApplicationService.GetPaymentTypes(out transaction);

            var paymentType = (from p in paymentTypes where p.Description == "Visa" select p).First();

            Customer customer = new Customer();

            customer.FirstName                = "William";
            customer.LastName                 = "Gates";
            customer.EmailAddress             = "*****@*****.**";
            customer.PhoneNumber              = "08615976111157";
            customer.Address                  = "One Microsoft Way";
            customer.City                     = "Redmond";
            customer.Region                   = "WA";
            customer.PostalCode               = "98052-7329";
            customer.PaymentTypeID            = paymentType.PaymentTypeID;
            customer.CreditCardExpirationDate = Convert.ToDateTime("12/31/2014");
            customer.CreditCardSecurityCode   = "111";
            customer.CreditCardNumber         = "123111234";

            customerApplicationService.CreateCustomer(customer, out transaction);

            returnMessage = Utilities.GetReturnMessage(transaction.ReturnMessage);

            Assert.AreEqual(true, transaction.ReturnStatus, returnMessage);
        }
        public void ValidateCustomerWithCheckPayment()
        {
            TransactionalInformation transaction;

            CustomerApplicationService customerApplicationService = new CustomerApplicationService(customerDataService);
            List <PaymentType>         paymentTypes = customerApplicationService.GetPaymentTypes(out transaction);

            var paymentType = (from p in paymentTypes where p.Description == "Check" select p).First();

            Customer customer = new Customer();

            customer.FirstName     = "Bill";
            customer.LastName      = "Gates";
            customer.EmailAddress  = "*****@*****.**";
            customer.PhoneNumber   = "15976111157";
            customer.PaymentTypeID = paymentType.PaymentTypeID;
            customer.CreditLimit   = 1000.00m;

            customerDataService.CreateSession();
            CustomerBusinessRules customerBusinessRules = new CustomerBusinessRules();

            customerBusinessRules.ValidateCustomer(customer, customerDataService);
            customerDataService.CloseSession();

            string returnMessage = Utilities.GetReturnMessage(customerBusinessRules.ValidationMessage);

            Assert.AreEqual(true, customerBusinessRules.ValidationStatus, returnMessage);
        }
        public void ValidateCustomerWithCreditCardPayment()
        {
            TransactionalInformation transaction;

            CustomerApplicationService customerApplicationService = new CustomerApplicationService(customerDataService);
            List <PaymentType>         paymentTypes = customerApplicationService.GetPaymentTypes(out transaction);

            var paymentType = (from p in paymentTypes where p.Description == "Visa" select p).First();

            Customer customer = new Customer();

            customer.FirstName                = "Bill";
            customer.LastName                 = "Gates";
            customer.EmailAddress             = "*****@*****.**";
            customer.PhoneNumber              = "15976111157";
            customer.PaymentTypeID            = paymentType.PaymentTypeID;
            customer.CreditCardNumber         = "1112223333";
            customer.CreditCardExpirationDate = Convert.ToDateTime("12/31/2014");
            customer.CreditCardSecurityCode   = "111";

            customerDataService.CreateSession();
            CustomerBusinessRules customerBusinessRules = new CustomerBusinessRules();

            customerBusinessRules.ValidateCustomer(customer, customerDataService);
            customerDataService.CloseSession();

            string returnMessage = Utilities.GetReturnMessage(customerBusinessRules.ValidationMessage);

            Assert.AreEqual(true, customerBusinessRules.ValidationStatus, 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);
        }