public async void LoadProducts() { try { HappyTailsServiceRef.HappyTailsServiceClient client = new HappyTailsServiceRef.HappyTailsServiceClient(); prodList.ItemsSource = await client.GetAllProductsAsync(); } catch (Exception ex) { Message mess = new Message(); mess.ShowMessage("Unfortunately we are experiencing problems contacting the web service at the moment.\nPlease try again later.\nTechnical information: " + ex.Message); } }
public async void AddNewProduct() { try { HappyTailsServiceRef.HappyTailsServiceClient client = new HappyTailsServiceRef.HappyTailsServiceClient(); HappyTailsServiceRef.ProductInformation product = new HappyTailsServiceRef.ProductInformation(); Message m = new Message(); //There is nothing for now that checks if the product is new or already exists //Balance and ImagePath properties are not able to fill in for now //Checks is the text box has been filled in, and if has has a value (not null) it will be added to the product if (!String.IsNullOrEmpty(txtName.Text)) { product.Name = txtName.Text; } else { m.ShowMessage("Fill in Product name."); } if (!String.IsNullOrEmpty(txtBrand.Text)) { product.Brand = txtBrand.Text; } if (!String.IsNullOrEmpty(txtColor.Text)) { product.Color = txtColor.Text; } if (!String.IsNullOrEmpty(txtCategory.Text)) { product.AnimalCategory = txtCategory.Text; } if (!String.IsNullOrEmpty(txtDescription.Text)) { product.Description = txtDescription.Text; } if (!String.IsNullOrEmpty(txtPrice.Text)) { try { product.Price = decimal.Parse(txtPrice.Text); } catch (Exception ex) { m.ShowMessage("Please enter the Price in numbers.\nTechnical information: " + ex.Message); } } if (!String.IsNullOrEmpty(txtLength.Text)) { try { product.Length = decimal.Parse(txtLength.Text); } catch (Exception ex) { m.ShowMessage("Please enter the Length in numbers.\nTechnical information: " + ex.Message); } } if (!String.IsNullOrEmpty(txtHeight.Text)) { try { product.Height = decimal.Parse(txtHeight.Text); } catch (Exception ex) { m.ShowMessage("Please enter the Height in numbers.\nTechnical information: " + ex.Message); } } await client.AddProductAsync(product); Message mess = new Message(); mess.ShowMessage("Product added successfully!"); //Clear text boxes after the creation of a new product txtHeight.Text = string.Empty; txtLength.Text = string.Empty; txtDescription.Text = string.Empty; txtColor.Text = string.Empty; txtCategory.Text = string.Empty; txtBrand.Text = string.Empty; txtName.Text = string.Empty; txtPrice.Text = string.Empty; } catch (Exception ex) { Message mess = new Message(); mess.ShowMessage("Unfortunately we are experiencing problems contacting the web service at the moment.\nPlease try again later.\nTechnical information: " + ex.Message); } }
public async void AddNewCustomer() { try { HappyTailsServiceRef.HappyTailsServiceClient client = new HappyTailsServiceRef.HappyTailsServiceClient(); HappyTailsServiceRef.CustomerInformation customer = new HappyTailsServiceRef.CustomerInformation(); //Customers with a username and/or email that already exists can also be added - should not work in the future //Checks is the text box has been filled in, and if has has a value (not null) it will be added to the customer if (!String.IsNullOrEmpty(txtFirstname.Text)) { customer.Firstname = txtFirstname.Text; } else { Message m = new Message(); m.ShowMessage("Fill in Firstname."); } if (!String.IsNullOrEmpty(txtSurname.Text)) { customer.Surname = txtSurname.Text; } else { Message m = new Message(); m.ShowMessage("Fill in Surname."); } if (!String.IsNullOrEmpty(txtUsername.Text)) { customer.Username = txtUsername.Text; } else { Message m = new Message(); m.ShowMessage("Fill in Username."); } if (!String.IsNullOrEmpty(txtPassword.Text)) { customer.Password = txtPassword.Text; } else { Message m = new Message(); m.ShowMessage("Fill in Password."); } if (!String.IsNullOrEmpty(txtEmail.Text)) { customer.Email = txtEmail.Text; } else { Message m = new Message(); m.ShowMessage("Fill in Email."); } if (!String.IsNullOrEmpty(txtStreet.Text)) { customer.Street = txtStreet.Text; } if (!String.IsNullOrEmpty(txtZipCode.Text)) { try { customer.ZipCode = int.Parse(txtZipCode.Text); } catch (Exception ex) { Message m = new Message(); m.ShowMessage("Please enter the ZipCode in numbers."); } } await client.AddCustomerAsync(customer); Message mess = new Message(); mess.ShowMessage("Customer added successfully!"); //Clear text boxes after the creation of a new customer txtFirstname.Text = string.Empty; txtPassword.Text = string.Empty; txtStreet.Text = string.Empty; txtSurname.Text = string.Empty; txtZipCode.Text = string.Empty; txtUsername.Text = string.Empty; txtEmail.Text = string.Empty; } catch (Exception ex) { Message mess = new Message(); mess.ShowMessage("Unfortunately we are experiencing problems contacting the web service at the moment.\nPlease try again later.\nTechnical information: " + ex.Message); } }