public void TestAddToModelSuccess() { var customer = new Customer("Adam", "Hansen", "Test"); _customerModel.AddCustomer(customer); Assert.IsTrue(_customerModel.GetCustomers().Contains(customer)); }
public DataTable GetCustomers() { DataTable dt = new DataTable(); dt = obj.GetCustomers(); return(dt); }
/// <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(); } }
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)); }
private void GetCustomer() { CustomerModel oCuscomerM = new CustomerModel(); try { dgvCustomer.DataSource = oCuscomerM.GetCustomers(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
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()); }
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()); }
public HttpResponseMessage GetAllCustomers() { HttpResponseMessage httpResponseMessage = Request.CreateResponse(HttpStatusCode.OK, CustomerModel.GetCustomers().Customers); return(httpResponseMessage); }
public void RefreshList() { Customers = model.GetCustomers(); }