public void dodaj(object parametar) { IMobileServiceTable <FirmaBaza> userTableObj = App.MobileService.GetTable <FirmaBaza>(); Validacija vKupac = new Validacija(); Tuple <int, string> vUsername; Tuple <int, string> vPassword; Tuple <int, string> vEmail; Tuple <int, string> vNaziv; Tuple <int, string> vPasswordPotvrda; vUsername = vKupac.ValidirajUsernameKorisnika(firma.Username); vPassword = vKupac.ValidirajPasswordKorisnika(firma.Password); vEmail = vKupac.ValidirajEmailKorisnika(firma.Email); vNaziv = vKupac.ValidirajImeKorisnika(firma.Naziv); vPasswordPotvrda = vKupac.ValidirajPasswordPotvrduKorisnika(firma.Password, firma.PasswordPotvrda); int brojGreski = vUsername.Item1 + vPassword.Item1 + vEmail.Item1 + vEmail.Item1 + vPasswordPotvrda.Item1; if (brojGreski == 0) { FirmaBaza firmicaHehe = new FirmaBaza(firma.Naziv, firma.Username, firma.Password, firma.Email, firma.StanjeRacuna); userTableObj.InsertAsync(firmicaHehe); EtfKupon.getInstance().dajListuFirmi().Add(firma); NavigationService.Navigate(typeof(MainPage), new MainPage(this)); return; } string poruka = ""; if (vNaziv.Item1 != 0) { poruka += vNaziv.Item2 + '\n'; } if (vUsername.Item1 != 0) { poruka += vUsername.Item2 + '\n'; } if (vPassword.Item1 != 0) { poruka += vPassword.Item2 + '\n'; } if (vEmail.Item1 != 0) { poruka += vEmail.Item2 + '\n'; } if (vPasswordPotvrda.Item1 != 0) { poruka += vPasswordPotvrda.Item2 + '\n'; } if (poruka != null) { new MessageDialog(poruka).ShowAsync(); } }
public IEnumerable GetErrors(string propertyName) { Validacija vKupac = new Validacija(); Tuple <int, string> vAdresa; Tuple <int, string> vIme; Tuple <int, string> vPrezime; Tuple <int, string> vUsername; Tuple <int, string> vPassword; Tuple <int, string> vEmail; vAdresa = vKupac.ValidirajAdresuKorisnika(this.Adresa); vIme = vKupac.ValidirajImeKorisnika(this.Ime); vPrezime = vKupac.ValidirajPrezimeKorisnika(this.Prezime); vUsername = vKupac.ValidirajUsernameKorisnika(this.Username); vPassword = vKupac.ValidirajPasswordKorisnika(this.Password); vEmail = vKupac.ValidirajEmailKorisnika(this.Email); string error = null; switch (propertyName) { case "Adresa": error = vAdresa.Item2; break; case "Ime": error = vAdresa.Item2; break; case "Prezime": error = vAdresa.Item2; break; case "Username": error = vUsername.Item2; break; case "Password": error = vPassword.Item2; break; case "Email": error = vEmail.Item2; break; } return(error); //throw new NotImplementedException(); }
public void dodaj(object parametar) { IMobileServiceTable <KupacBaza> userTableObj = App.MobileService.GetTable <KupacBaza>(); //IMobileServiceTable<proba> blabla = App.MobileService.GetTable<proba>(); Validacija vKupac = new Validacija(); Tuple <int, string> vAdresa; Tuple <int, string> vIme; Tuple <int, string> vPrezime; Tuple <int, string> vUsername; Tuple <int, string> vPassword; Tuple <int, string> vEmail; Tuple <int, string> vPasswordPotvrda; vAdresa = vKupac.ValidirajAdresuKorisnika(Kupac.Adresa); vIme = vKupac.ValidirajImeKorisnika(Kupac.Ime); vPrezime = vKupac.ValidirajPrezimeKorisnika(Kupac.Prezime); vUsername = vKupac.ValidirajUsernameKorisnika(Kupac.Username); vPassword = vKupac.ValidirajPasswordKorisnika(Kupac.Password); vEmail = vKupac.ValidirajEmailKorisnika(Kupac.Email); vPasswordPotvrda = vKupac.ValidirajPasswordPotvrduKorisnika(Kupac.Password, Kupac.PasswordPotvrda); int suma = vAdresa.Item1 + vIme.Item1 + vPrezime.Item1 + vPassword.Item1 + vEmail.Item1 + vUsername.Item1 + vPasswordPotvrda.Item1; if (suma == 0) { KupacBaza x = new KupacBaza(Kupac.Ime, Kupac.Prezime, Kupac.Username, Kupac.Password, Kupac.Email, Kupac.Adresa, Kupac.BrojKartice, Kupac.StanjeRacuna); EtfKupon.getInstance().dodajKupca(Kupac); userTableObj.InsertAsync(x); NavigationService.Navigate(typeof(MainPage), new MainPage(this)); return; } string poruka = ""; if (vAdresa.Item1 != 0) { poruka += vAdresa.Item2 + '\n'; } if (vIme.Item1 != 0) { poruka += vIme.Item2 + '\n'; } if (vPrezime.Item1 != 0) { poruka += vPrezime.Item2 + '\n'; } if (vUsername.Item1 != 0) { poruka += vUsername.Item2 + '\n'; } if (vPassword.Item1 != 0) { poruka += vPassword.Item2 + '\n'; } if (vEmail.Item1 != 0) { poruka += vEmail.Item2 + '\n'; } if (vPasswordPotvrda.Item1 != 0) { poruka += vPasswordPotvrda.Item2 + '\n'; } if (poruka != null) { new MessageDialog(poruka).ShowAsync(); } //CloseAction(); }