Example #1
0
        public void TestAddToModelSuccess()
        {
            var customer = new Customer("Adam", "Hansen", "Test");

            _customerModel.AddCustomer(customer);

            Assert.IsTrue(_customerModel.GetCustomers().Contains(customer));
        }
Example #2
0
 public void Add()
 {
     TestServiceReference.Customer newCustomer = new TestServiceReference.Customer();
     newCustomer.Address   = this.Address;
     newCustomer.Phone     = this.Phone;
     newCustomer.LastName  = this.LastName;
     newCustomer.FirstName = this.FirstName;
     model.AddCustomer(newCustomer);
     RefreshList();
 }
Example #3
0
        public bool AddCustomer()
        {
            string Phone   = View.Phone;
            string CusName = View.CusName;
            string Email   = View.Email;
            string Address = View.Address;

            CustomerInfo ci = new CustomerInfo(Phone, CusName, Email, Address, true);

            return(CustomerModel.AddCustomer(ci));
        }
Example #4
0
        public void TestGetCustomerById()
        {
            _customerModel = new CustomerModel();

            var customer   = new Customer("Adam", "Hansen", "Test");
            var customerId = customer.Id;

            _customerModel.AddCustomer(customer);

            var customerFromModel = _customerModel.GetCustomerById(customerId);

            Assert.True(customer.Id == customerFromModel.Id);
        }
Example #5
0
        public void TestDeleteFromModelSuccess()
        {
            _customerModel = new CustomerModel();

            var customer = new Customer("Adam", "Hansen", "Test");

            var customerId = customer.Id;

            _customerModel.AddCustomer(customer);

            _customerModel.DeleteCustomerById(customerId);

            Assert.False(_customerModel.GetCustomers().Any());
        }
Example #6
0
        /// <summary>
        /// Add new customer
        /// </summary>
        public string AddCustomer(CustomerViewModel customer)
        {
            CustomerModel model = new CustomerModel();

            if (customer != null)
            {
                model.AddCustomer(customer);
                return("Customer added successfully");
            }
            else
            {
                return("Invalid customer record");
            }
        }
Example #7
0
        /// <summary>
        /// Give user option to add a customer
        /// </summary>
        private static void DisplayAddCustomer()
        {
            Console.Write("Please Enter First Name: ");
            var firstName = MenuManager.GetValidString();

            Console.Write("Please Enter Last Name: ");
            var lastName = MenuManager.GetValidString();

            Console.Write("Please Enter Address: ");
            var address = MenuManager.GetValidString();

            var newCustomer = new Customer(firstName, lastName, address);

            try
            {
                CustomerModel.AddCustomer(newCustomer);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
 public ActionResult CreateSubscriber(SiteSubscriber obj)
 {
     if (ModelState.IsValid)
     {
         Guid guid = new Guid();
         Random rnmd = new Random();
         PinPaymentsDbEntities db = new PinPaymentsDbEntities();
         if (ModelState.IsValid)
         {
             tblCustomer obtbl = new tblCustomer();
             CustomerModel model = new CustomerModel();
             int cutomerid = model.AddCustomer(obj);
             xml = "<subscriber><customer-id>" + cutomerid + "</customer-id><screen-name>" + obj.FirstName + obj.LastName + "</screen-name></subscriber>";
             site = ConfigurationManager.AppSettings["apiUrl"].ToString();
             url = string.Format("https://subs.pinpayments.com/api/v4/{0}/subscribers.xml", site);
             CreateSubscriberApi(url, xml, "Post");
             CardDetail obj1 = new CardDetail();
             obj1.token = GenrateInvoice(obj.SubscriptionId, cutomerid.ToString(), obj.FirstName, obj.Email);
             obj1.firstName = obj.FirstName;
             obj1.lastName = obj.LastName;
             ViewBag.year = DBCommon.BindYear();
             ViewBag.month = DBCommon.BindMonth();
             return RedirectToAction("AddCardDetail", obj1);
         }
         return View("CreateSubscriber");
     }
     else
     {
         return View(obj);
     }
 }
Example #9
0
        public ActionResult <Customer> Post([FromBody] Customer customer)
        {
            var cust = _customerModel.AddCustomer(customer);

            return(CreatedAtAction(nameof(GetById), new { id = cust.CustomerId }, cust));
        }