private void Register_Click(object sender, RoutedEventArgs e)
        {
            Registration reg = new Registration();
            reg.Username = usernameTxt.Text;
            reg.Password_1 = password1Txt.Password;
            reg.Password_2 = password2Txt.Password;
            reg.Email_1 = email1Txt.Text;
            reg.Email_2 = email2Txt.Text;
            reg.Gender = ((String)genderPicker.SelectedItem).Substring(0, 1);
            reg.Unit = ((MeasurementSystem)msPicker.SelectedItem).ToString().Substring(0, 2).ToLower();
            reg.Weight = (int)Double.Parse(weightTxt.Text);
            reg.Height = (int)Double.Parse(heightTxt.Text);
            reg.Birthdate = ((DateTime)birthdayPicker.Value).ToString("yyyy-MM-dd");
            App.MealViewModel.MainLogic.Register(reg);

            Preference p = App.MealViewModel.Preference;
            p.Username = reg.Username;
            p.Password = reg.Password_1;
            p.MeasurementSystem = (MeasurementSystem)msPicker.SelectedItem;
            App.MealViewModel.MsPicker.SelectedItem = p.MeasurementSystem;

            User u = App.MealViewModel.User;
            if (u.Weight == null)
                u.Weight = new Weight();
            u.Weight.WeightValue = reg.Weight;
            u.Weight.Date = DateTime.Now;
            u.Height = reg.Height;
            u.CalcBmi();
            App.MealViewModel.WeightBox.Text = u.Weight.WeightValue.ToString();
            u.WeightSyncedToday = true;

            App.MealViewModel.RegistrationFailedTxt = "";
            NavigationService.GoBack();
        }
 public void Register(Registration reg)
 {
     String para = "&username="******"&password_1=" + reg.Password_1 + "&password_2=" + reg.Password_2
          + "&email_1=" + reg.Email_1 + "&email_2=" + reg.Email_2 + "&gender=" + reg.Gender + "&unit=" + reg.Unit
           + "&weight=" + reg.Weight + "&height=" + reg.Height + "&birthdate=" + reg.Birthdate;
     SendRequest(RequestType.REGISTER, para, false, (int)KindsOfConnection.Download);
 }