private async void btnSacuvaj_Click(object sender, EventArgs e) { if (ValidateChildren()) { var roleList = clbRole.CheckedItems.Cast <OnlineGym_Model.Uloga>().Select(x => x.UlogaId).ToList(); request.Email = txtEmail.Text; request.Ime = txtIme.Text; request.KorisnickoIme = txtKorisnickoIme.Text; request.Password = txtPassword.Text; request.PasswordPotvrda = txtPassPotvrda.Text; request.Prezime = txtPrezime.Text; request.Telefon = txtTelefon.Text; request.Uloge = roleList; OnlineGym_Model.Korisnik entity = null; entity = await _korisnici.Insert <OnlineGym_Model.Korisnik>(request); if (entity != null) { MessageBox.Show("Uspješno izvršeno"); this.Close(); } } }
private async void btnSacuvaj_Click(object sender, EventArgs e) { if (ValidateChildren()) { var entity1 = await _korisnici.GetById <OnlineGym_Model.Korisnik>(_id); if (AddSlika == false) { request.Fotografija = entity1.Fotografija; request.FotografijaThum = entity1.FotografijaThum; } request.Ime = labIme.Text; request.Prezime = labPrezime.Text; request.Telefon = labTelefon.Text; request.Email = labEmail.Text; request.Adresa = labAdresa.Text; request.KorisnickoIme = labKorisnickoIme.Text; request.StariPassword = labStaraLozinka.Text; request.Password = labLozinka.Text; request.PasswordPotvrda = labLozinkaPotvrda.Text; OnlineGym_Model.Korisnik entity = null; entity = await _korisnici.Update <OnlineGym_Model.Korisnik>(_id.Value, request); if (entity == null) { MessageBox.Show("Unesite ispravnu staru lozinku!"); return; } GlobalKorisnik.Username = labKorisnickoIme.Text; APIService.Username = GlobalKorisnik.Username; APIService.Password = labLozinka.Text; MessageBox.Show("Izmjene spašene!"); this.Close(); } }