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

            _customerModel.AddCustomer(customer);

            Assert.IsTrue(_customerModel.GetCustomers().Contains(customer));
        }
コード例 #2
0
        public DataTable GetCustomers()
        {
            DataTable dt = new DataTable();

            dt = obj.GetCustomers();
            return(dt);
        }
コード例 #3
0
        /// <summary>
        /// Give user option to edit a customer
        /// </summary>
        private static void DisplayEditCustomer()
        {
            ListAllCustomers();

            Console.WriteLine();

            if (CustomerModel.GetCustomers().Any())
            {
                Console.WriteLine("Please write id of customer to edit:");

                var customerIdInput = MenuManager.GetSelectedCustomerId(CustomerModel.GetCustomers());

                var selectedCustomer = CustomerModel.GetCustomerById(customerIdInput);

                CustomerManager.EditCustomer(selectedCustomer);

                Console.WriteLine("New customer info:");

                selectedCustomer.DisplayInfo();
            }
        }
コード例 #4
0
        public async Task <IActionResult> GetCustomers()
        {
            // return all customers
            // for demo purposes we will return a collection of fake customer record
            // Pass in  a Link Generator Test 1 : to the get Customer record

            // we need a delegate that accepts a Url.Link generator and return a string
            //Func<UrlHelper, string> linkGen = helper => { return helper.Link(nameof(GetCustomer), new {id = "abcd"}); };
            ApiResponse <IEnumerable <CustomerModel> > res = await CustomerModel.GetCustomers(Url);

            res.RootHref = Url.Link(nameof(RootApiController.Get), null);
            return(Ok(res));
        }
コード例 #5
0
        private void GetCustomer()
        {
            CustomerModel oCuscomerM = new CustomerModel();

            try
            {
                dgvCustomer.DataSource = oCuscomerM.GetCustomers();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
コード例 #6
0
 public IHttpActionResult AddCustomer(Customer customer)
 {
     if (customer != null)
     {
         var existCustomer = CustomerModel.GetCustomers().Customers.FirstOrDefault(p => p.Id == customer.Id);
         if (existCustomer != null)
         {
             throw new Exception("Customer already exists");
         }
         CustomerModel.GetCustomers().Customers.Add(customer);
         return(Ok(customer));
     }
     return(NotFound());
 }
コード例 #7
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());
        }
コード例 #8
0
        public HttpResponseMessage GetAllCustomers()
        {
            HttpResponseMessage httpResponseMessage = Request.CreateResponse(HttpStatusCode.OK, CustomerModel.GetCustomers().Customers);

            return(httpResponseMessage);
        }
コード例 #9
0
 public void RefreshList()
 {
     Customers = model.GetCustomers();
 }