public Customer Add(Customer customer)
 {
     var added = _dataService.AddCustomer(customer);
     _allCustomers.Add(added);
     _allCustomers.Sort();
     return added;
 }
Beispiel #2
0
 public void RemoveCustomer(Customer customer)
 {
     using (var entities = new HillStationEntities())
     {
         var customerEntity = entities.Customers.Find(customer.Id);
         entities.Customers.Remove(customerEntity);
         entities.SaveChanges();
     }
 }
Beispiel #3
0
 public Customer AddCustomer(Customer customer)
 {
     using (var entities = new HillStationEntities())
     {
         entities.Customers.Add(customer);
         entities.SaveChanges();
         entities.Entry(customer).Reload();
         return customer;
     }
 }
Beispiel #4
0
 public void UpdateCustomer(Customer customer)
 {
     using (var entities = new HillStationEntities())
     {
         var customerEntity = entities.Customers.Find(customer.Id);
         customerEntity.Name = customer.Name;
         customerEntity.Address = customer.Address;
         customerEntity.Postcode = customer.Postcode;
         customerEntity.Phone = customer.Phone;
         entities.SaveChanges();
     }
 }
 private void CustomerChanged(object sender, EventArgs e)
 {
     SelectedCustomer = (Customer) Customers.CurrentItem;
     OnSelectedCustomerChangedEvent(SelectedCustomer);
 }
 public void DeleteCustomer(Customer customer)
 {
     _data.Remove(customer);
     Customers.Refresh();
 }
 public void AddCustomer(Customer customer)
 {
     _data.Add(customer);
     Customers.Refresh();
     Customers.MoveCurrentTo(customer);
 }
 private void OnSelectedCustomerChangedEvent(Customer customer)
 {
     SelectedCustomerChangedEvent?.Invoke(this, new CustomerListEventArgs {Customer = customer});
 }
 private void SelectCustomer(object sender, MouseButtonEventArgs e)
 {
     Customer = (Customer) ((ListBox) sender).SelectedItem;
 }
 private void SetFields(Customer value)
 {
     if (value == null)
     {
         Name = string.Empty;
         Address = string.Empty;
         Postcode = string.Empty;
         Phone = string.Empty;
     }
     else
     {
         Name = value.Name;
         Address = value.Address;
         Postcode = value.Postcode;
         Phone = value.Phone;
     }
 }
 private void Save()
 {
     // Save/Update the customer
     // First detach so we don't update the database
     var customer = _adding ? new Customer() : SelectedCustomer;
     customer.Name = Name;
     customer.Address = Address;
     customer.Postcode = Postcode;
     customer.Phone = Phone;
     if (_adding)
     {
         AddCustomer(customer);
         SelectedCustomer = customer;
     }
     IsEditing = false;
 }
 private void AddCustomer(Customer customer)
 {
     var count = 0;
     var added = false;
     foreach (var current in Customers)
     {
         if (customer.CompareTo(current) < 0)
         {
             Customers.Insert(count, customer);
             added = true;
             break;
         }
         count++;
     }
     if (!added) Customers.Add(customer);
 }
Beispiel #13
0
 private void AddCustomer(object sender, RoutedEventArgs e)
 {
     var customer = new Customer {Name = $"Dame {_count++}"};
     CustomerList.AddCustomer(customer);
 }
 public void UpdateCustomer(Customer customer)
 {
     throw new NotImplementedException();
 }
 public Customer AddCustomer(Customer customer)
 {
     throw new NotImplementedException();
 }
 public void DeleteCustomer(Customer customer)
 {
     _model.DeleteCustomer(customer);
 }
 public void AddCustomer(Customer customer)
 {
     _model.AddCustomer(customer);
 }