Пример #1
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            this.SetContentView(Resource.Layout.register);
            username        = FindViewById <EditText>(Resource.Id.txtUsernameReg);
            password        = FindViewById <EditText>(Resource.Id.txtZaporkaReg);
            password2       = FindViewById <EditText>(Resource.Id.txtPonoviReg);
            name            = FindViewById <EditText>(Resource.Id.txtImeReg);
            surname         = FindViewById <EditText>(Resource.Id.txtPrezimeReg);
            moto            = FindViewById <EditText>(Resource.Id.txtMotoReg);
            about           = FindViewById <EditText>(Resource.Id.txtOMeniReg);
            piccbutt        = FindViewById <Button>(Resource.Id.btnSlika);
            regg            = FindViewById <Button>(Resource.Id.btnReg);
            img             = FindViewById <ImageView>(Resource.Id.imgReg);
            piccbutt.Click += delegate
            {
                var imageIntent = new Intent();
                imageIntent.SetType("image/*");
                imageIntent.SetAction(Intent.ActionGetContent);
                StartActivityForResult(
                    Intent.CreateChooser(imageIntent, "Select photo"), 0);
            };

            regg.Click += delegate
            {
                if (username.Text.Equals(String.Empty) || password.Text.Equals(String.Empty) || password2.Text.Equals(String.Empty) || name.Text.Equals(String.Empty) || surname.Text.Equals(String.Empty))
                {
                    Toast.MakeText(this, "Prvih 5 polja su obavezna!", ToastLength.Short).Show();
                }
                else if (password.Text != password2.Text)
                {
                    Toast.MakeText(this, "Lozinka i ponovljena lozinka nisu iste!", ToastLength.Short).Show();
                }
                else
                {
                    KorisnikModelMob korisnik = new KorisnikModelMob();
                    korisnik.Username = username.Text;
                    korisnik.Ime      = name.Text;
                    korisnik.Prezime  = surname.Text;
                    korisnik.Lozinka  = password.Text;
                    korisnik.Moto     = moto.Text;
                    korisnik.Opis     = about.Text;
                    if (slika != null && slika.Length > 5)
                    {
                        korisnik.Slika = slika;
                    }
                    connection(korisnik);
                    Intent activity = new Intent(this, typeof(Login));
                    StartActivity(activity);
                }
            };
        }
Пример #2
0
        private async Task SaveTodoItemAsync(KorisnikModelMob korisnik)
        {
            HttpClient client = new HttpClient();
            string     uri    = "http://bucketlist.ddns.net/api/korisnik/register";

            var json    = JsonConvert.SerializeObject(korisnik);
            var content = new StringContent(json, Encoding.UTF8, "application/json");

            HttpResponseMessage response = null;

            response = await client.PostAsync(uri, content);

            if (response.IsSuccessStatusCode)
            {
                Toast.MakeText(this, "Uspješno registriran novi korisnik!", ToastLength.Short).Show();
            }
            else
            {
                Toast.MakeText(this, "Greška", ToastLength.Short).Show();
            }
        }
Пример #3
0
 private async void connection(KorisnikModelMob korisnik)
 {
     await SaveTodoItemAsync(korisnik);
 }