コード例 #1
0
        public async Task <bool> Registruj(string ime, string prezime, string adresa, string email,
                                           string korisnickoIme, string lozinka, DateTime datum)
        {
            Windows.Web.Http.HttpClient httpClient = new Windows.Web.Http.HttpClient();
            var    headers = httpClient.DefaultRequestHeaders;
            string header  = "ie";

            if (!headers.UserAgent.TryParseAdd(header))
            {
                throw new Exception("Invalid header value: " + header);
            }
            header = "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; WOW64; Trident/6.0)";
            if (!headers.UserAgent.TryParseAdd(header))
            {
                throw new Exception("Invalid header value: " + header);
            }
            //string stri = Convert.ToBase64String(Image);
            //MessageDialog showDialog = new MessageDialog(ime + prezime +email + adresa);
            //await showDialog.ShowAsync();
            korisnik = new Models.FizickoLice(ime, prezime, adresa, email, korisnickoIme, lozinka, datum);

            Uri requestUri = new Uri("http://localhost:60625/FizickoLice/Add/" + "?ime=" + korisnik.Ime +
                                     "&prezime=" + korisnik.prezime + "&adresa=" + korisnik.adresa + "&email=" + korisnik.email +
                                     "&korisnickoIme=" + korisnik.korisnickoIme + "&lozinka=" + korisnik.lozinka + "&datum=" +
                                     korisnik.datumRodjenja);

            Windows.Web.Http.HttpResponseMessage httpResponse = new Windows.Web.Http.HttpResponseMessage();
            string httpResponseBody = "";


            try
            {
                //var success = await Windows.System.Launcher.LaunchUriAsync(requestUri);
                httpResponse = await httpClient.PostAsync(requestUri, null);

                string json = httpResponseBody;
                httpResponse.EnsureSuccessStatusCode();
                httpResponseBody = await httpResponse.Content.ReadAsStringAsync();
            }
            catch (Exception ex)
            {
                httpResponseBody = "Error: " + ex.HResult.ToString("X") + " Message: " + ex.Message;
            }
            return(true);
        }
コード例 #2
0
        private async void potvrda_Click(object sender, RoutedEventArgs e)
        {
            string   ime        = ime1Box.Text;
            string   prezime    = prezimeBox.Text;
            string   adresa     = adresaBox.Text;
            string   email      = emailBox.Text;
            string   korisnicko = imeBox.Text;
            string   lozinka    = sifraBox.Password.ToString();
            string   potvrda    = potvrdasifrebox.Password.ToString();
            DateTime datum      = date.Date.DateTime;


            greska1.Foreground = new SolidColorBrush(Colors.Red);

            if (ime.Length == 0 || prezime.Length == 0 || adresa.Length == 0 || email.Length == 0 || korisnicko.Length == 0)
            {
                greska1.Text = "Morate popuniti sva polja!";
            }
            else if (MainPage.Validacija(adresa, email, korisnicko, lozinka, potvrda, greska1))
            {
                greska1.Text = " ";
                Models.FizickoLice novo = new Models.FizickoLice();
                novo.id            = 0;
                novo.Ime           = ime;
                novo.prezime       = prezime;
                novo.adresa        = adresa;
                novo.email         = email;
                novo.korisnickoIme = korisnicko;
                novo.lozinka       = lozinka;

                tabelaFizickoLice.InsertAsync(novo);

                Boolean b = await flvm.Registruj(ime, prezime, adresa, email, korisnicko, lozinka, datum);

                if (b)
                {
                    MessageDialog showDialog = new MessageDialog("Uspješno ste se registrovali");
                    await showDialog.ShowAsync();
                }
            }
        }