Example #1
0
        private void button_update_click(object sender, RoutedEventArgs e)
        {
            //Address local creation
            LocationServiceReference.Address address = new LocationServiceReference.Address();
            address.Id          = readBar.Address.Id;
            address.AddressName = textbox_address.Text;
            int zipcodeId = Int32.Parse(combobox_zipcodes.SelectedValue.ToString());

            //Save address to db and return with Id
            LocationServiceReference.Address barAddress = locationService.updateAddress(address, zipcodeId);

            //Here we "transfer" the LocationServiceReference.Address object to a BarServiceReference.Address object :S
            BarServiceReference.Address referenceAddress = new BarServiceReference.Address();
            referenceAddress.Id = barAddress.Id;

            //BAR
            string name     = textbox_name.Text;
            string phone    = textbox_phone.Text;
            string email    = textbox_email.Text;
            string username = textbox_username.Text;

            bool success = barService.Update(readBar.ID, name, referenceAddress, phone, email, username);

            if (success)
            {
                MessageBox.Show("Your bar was updated");
                this.Close();
                mainWindow.Show();
                mainWindow.show_bars();
            }
        }
Example #2
0
        //TODO Kald ikke LocationService, men lad barService gøre det hele
        private void button_create_click(object sender, RoutedEventArgs e)
        {
            Adresse AddressObject = (Adresse)combobox_address.SelectedItem;
            string  addressName   = (AddressObject.adgangsadresse.vejstykke.navn + " " + AddressObject.adgangsadresse.husnr + " " + AddressObject.etage + " " + AddressObject.dør).Trim();

            if (ValidateEmail() && ValidatePhone())
            {
                //int zipcodeId = Int32.Parse(combobox_zipcodes.SelectedValue.ToString());
                LocationServiceReference.Address address = locationService.createAddress(addressName, Convert.ToInt32(AddressObject.adgangsadresse.postnummer.nr)); //skal være en BarServiceReference.Address
                string barName  = textbox_name.Text;
                string phone    = textbox_phone.Text;
                string email    = textbox_email.Text;
                string username = textbox_username.Text;
                string password = passwordbox_password.Password;

                //Here we "transfer" the LocationServiceReference.Address object to a BarServiceReference.Address object :S
                BarServiceReference.Address referenceAddress = new BarServiceReference.Address();
                referenceAddress.Id = address.Id;

                Bar bar = barService.Create(1, barName, referenceAddress, phone, email, username, password);

                if (bar != null)
                {
                    MessageBox.Show("Your bar was created");
                    this.Close();
                    mainWindow.Show();
                    mainWindow.show_bars();
                }
            }
        }