async Task Login() { IsBusy = true; bool userIsServiser = false; bool userIsKorisnik = false; try { KorisniciModel korisnik = await _service.Authenticate <KorisniciModel>(Username, Password); if (korisnik != null) { foreach (var item in korisnik.KorisniciUloge) { if (item.Uloga.Naziv == "serviser") { userIsServiser = true; APIService.Username = Username; APIService.Password = Password; APIService.KorisnikId = item.KorisnikId; } else if (item.Uloga.Naziv == "korisnik") { userIsKorisnik = true; APIService.Username = Username; APIService.Password = Password; APIService.KorisnikId = item.KorisnikId; } } if (userIsServiser) { Application.Current.MainPage = new AppShellServiser(); } else if (userIsKorisnik) { Application.Current.MainPage = new AppShell(); } else { await Application.Current.MainPage.DisplayAlert("Greška", "Korisnik mora biti pod Serviser ili Korisnik rolom", "OK"); } } else { await Application.Current.MainPage.DisplayAlert("Greška", "Pogrešan Username ili Password", "OK"); } } catch { } }
public async void btnLogin_Click(object sender, EventArgs e) { try { KorisniciModel korisnik = await _service.Authenticate <KorisniciModel>(txtUsername.Text, txtPassword.Text); bool userIsAdmin = false; if (korisnik != null) { foreach (var item in korisnik.KorisniciUloge) { if (item.Uloga.Naziv == "admin") { userIsAdmin = true; APIService.Username = txtUsername.Text; APIService.Password = txtPassword.Text; } } if (userIsAdmin) { MessageBox.Show("Dobrodosli " + korisnik.Ime + " " + korisnik.Prezime); DialogResult = DialogResult.OK; } else { MessageBox.Show("Samo administratori imaju pristup desktop aplikaciji", "Autentifikacija", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show("Pogresan username ili password", "Autentifikacija", MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Authentikacija", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private async void btnPrikazi_Click(object sender, EventArgs e) { errorProvider1.SetError(listServiseri, null); if (listServiseri.SelectedValue == null) { errorProvider1.SetError(listServiseri, "Izaberi servisera"); } else { KorisniciModel selectedItem = (KorisniciModel)listServiseri.SelectedItem; var search = new SearchRequestServis() { ImeServisera = selectedItem.Ime, KoristiDatum = checkBox.Checked, DatumServisa = dateTimePicker1.Value }; var servisi = await _servisiService.GetParam <List <Model.ServisModel> >("GetServisiList", search); ReportDataSource rds = new ReportDataSource("DataSet1", servisi); this.reportViewer1.LocalReport.DataSources[0] = rds; this.reportViewer1.RefreshReport(); } }