private void btnCreate_Click(object sender, EventArgs e) { using (CustomerSTEServiceClient proxy = new CustomerSTEServiceClient()) { var cust = new OrderIT.Model.STE.Customer() { Name = CustomerName.Text, BillingAddress = new OrderIT.Model.STE.AddressInfo() { Address = BillingAddress.Text, City = BillingCity.Text, Country = BillingCountry.Text, ZipCode = BillingZipCode.Text }, ShippingAddress = new OrderIT.Model.STE.AddressInfo() { Address = ShippingAddress.Text, City = ShippingCity.Text, Country = ShippingCountry.Text, ZipCode = ShippingZipCode.Text }, }; var id = proxy.CreateCustomerUsingSTE(cust); MessageBox.Show("Customer created with id " + id); } }
private void btnDelete_Click(object sender, EventArgs e) { using (CustomerSTEServiceClient proxy = new CustomerSTEServiceClient()) { _customer.ChangeTracker.State = Model.STE.ObjectState.Deleted; proxy.DeleteCustomerUsingSTE(_customer); MessageBox.Show("Customer deleted"); } }
private static void GetandUpdateCustomer() { try { using (CustomerSTEServiceClient proxy = new CustomerSTEServiceClient()) { var custList = proxy.GetCustomerPickList(); int randomCustomerID = custList[8].Id; BAGA.Customer customer = proxy.GetCustomer(randomCustomerID); customer.Notes = "new notes " + DateTime.Now.ToShortTimeString(); List <Trip> trips = proxy.GetUpcomingTrips(); BAGA.Reservation newRes = new Reservation(); //emulate selection of trip from list of trips newRes.ReservationDate = DateTime.Now; newRes.TripID = trips[12].TripID; //create a default value for binary field newRes.TimeStamp = System.Text.Encoding.Default.GetBytes("0x123"); if (customer.Reservations == null) { customer.Reservations = new TrackableCollection <Reservation>(); } else { //modify a reservation customer.Reservations[0].ReservationDate = customer.Reservations[0].ReservationDate.AddDays(1); if (customer.Reservations.Count > 1) { var resDelete = customer.Reservations[customer.Reservations.Count - 1]; resDelete.MarkAsDeleted(); } } customer.Reservations.Add(newRes); newRes.ContactID = customer.ContactID; string status = proxy.SaveCustomer(customer); Console.WriteLine(status); } } catch (Exception ex) { throw ex; } }
private void btnUpdate_Click(object sender, EventArgs e) { using (CustomerSTEServiceClient proxy = new CustomerSTEServiceClient()) { _customer.Name = CustomerName.Text; _customer.BillingAddress.Address = BillingAddress.Text; _customer.BillingAddress.City = BillingCity.Text; _customer.BillingAddress.Country = BillingCountry.Text; _customer.BillingAddress.ZipCode = BillingZipCode.Text; _customer.ShippingAddress.Address = ShippingAddress.Text; _customer.ShippingAddress.City = ShippingCity.Text; _customer.ShippingAddress.Country = ShippingCountry.Text; _customer.ShippingAddress.ZipCode = ShippingZipCode.Text; _customer.ChangeTracker.State = Model.STE.ObjectState.Modified; proxy.UpdateCustomerUsingSTE(_customer); MessageBox.Show("Customer updated"); } }
private void btnRetrieveById_Click(object sender, EventArgs e) { using (CustomerSTEServiceClient proxy = new CustomerSTEServiceClient()) { _customer = proxy.ReadCustomerUsingSTE(Convert.ToInt32(CustomerId.Text)); CustomerName.Text = _customer == null ? String.Empty :_customer.Name; CustomerId.Tag = _customer == null ? null :_customer.Version; BillingAddress.Text = _customer == null ? String.Empty :_customer.BillingAddress.Address; BillingCity.Text = _customer == null ? String.Empty :_customer.BillingAddress.City; BillingCountry.Text = _customer == null ? String.Empty :_customer.BillingAddress.Country; BillingZipCode.Text = _customer == null ? String.Empty :_customer.BillingAddress.ZipCode; ShippingAddress.Text = _customer == null ? String.Empty :_customer.ShippingAddress.Address; ShippingCity.Text = _customer == null ? String.Empty :_customer.ShippingAddress.City; ShippingCountry.Text = _customer == null ? String.Empty :_customer.ShippingAddress.Country; ShippingZipCode.Text = _customer == null ? String.Empty :_customer.ShippingAddress.ZipCode; if (_customer == null) { MessageBox.Show("UserID doesn't exist"); } } }