// POST api/values public void Post(Customer cust) { CustomerManagement custMgmt = new CustomerManagement(); custMgmt.AddCustomer(cust); }
private void btnAdd_Click(object sender, EventArgs e) { if (txtName.isEmptyOrHint()) { txtName.Focus(); return; } if (txtAddress1.isEmptyOrHint()) { txtAddress1.Focus(); return; } if (txtCity.isEmptyOrHint()) { txtCity.Focus(); return; } if (txtCountry.isEmptyOrHint()) { txtCountry.Focus(); return; } if (txtPostalAddress.isEmptyOrHint()) { txtPostalAddress.Focus(); return; } if (txtPhoneNumber.isEmptyOrHint()) { txtPhoneNumber.Focus(); return; } Customer c = new Customer(); c.Name = txtName.Text.Trim(); c.PhoneNumber = txtPhoneNumber.Text.Trim(); c.PostalAddress = txtPostalAddress.Text.Trim(); c.City = txtCity.Text.Trim(); c.Country = txtCountry.Text.Trim(); c.Address2 = txtAddress2.isEmptyOrHint() ? "":txtAddress2.Text.Trim(); c.Address1 = txtAddress1.Text.Trim(); CurrentCustomer = c; if (Update) { CurrentCustomer.ID = UpdateID; c.ID = UpdateID; m.UpdateCustomer(c); CustomerUpdated?.Invoke(); } else { CurrentCustomer.ID = m.AddCustomer(c); //MessageBox.Show(c.ID); NewCustomerAdded?.Invoke(); } Reset(); this.Hide(); }