public void OnNavigatedTo(NavigationContext navigationContext) { var parameter = navigationContext.Parameters.FirstOrDefault(p => p.Key == "CustomerId"); if (parameter.Value != null) { if (CustomerList.Count == 0) { var principal = Thread.CurrentPrincipal as SystemPrincipal; var agentId = principal.Identity.Id; var customers = _customerService.GetCustomersBy(agentId); SelectedCustomer = customers.FirstOrDefault(c => c.Id == int.Parse(parameter.Value.ToString())); } else { SelectedCustomer = CustomerList.FirstOrDefault(c => c.Id == int.Parse(parameter.Value.ToString())); } } else { parameter = navigationContext.Parameters.FirstOrDefault(p => p.Key == "Customer"); if (parameter.Value != null) { SelectedCustomer = parameter.Value as Customer; } } }
public void DeleteTest() { CustomerList customers = new CustomerList(); customers.Load(); //Find the customer with the description testingcustomer Customer customer = customers.FirstOrDefault(c => c.FirstName == "Test"); //Delete it int result = customer.Delete(); Assert.IsTrue(result == 1); }
public void UpdateTest() { CustomerList customers = new CustomerList(); customers.Load(); //Find the customer with the description testingcustomer Customer customer = customers.FirstOrDefault(c => c.FirstName == "Test"); //Update it and insert it customer.LastName = "UpdatedCustomer"; int result = customer.Update(); Assert.IsTrue(result == 1); }
private void InitializeData() { var principal = Thread.CurrentPrincipal as SystemPrincipal; var agentId = principal.Identity.Id; var customers = _customerService.GetCustomersBy(agentId); Application.Current.Dispatcher.BeginInvoke(new Action(() => { CustomerList.AddRange(customers); if (SelectedCustomer != null) { SelectedCustomer = CustomerList.FirstOrDefault(c => c.Id == SelectedCustomer.Id); } else { SelectedCustomer = CustomerList.Count == 0 ? null : CustomerList[0]; } })); }