public Zamestnanec AuthorizeNamePass(string name, string pass) { var encPassword = ShaEncrypter.Hash(pass); var data = GetContext(); if (data.Zamestnanec.Any(i => i.Login == name && i.Heslo == encPassword)) { return(data.Zamestnanec.First(i => i.Login == name && i.Heslo == encPassword)); } return(null); }
private void pridatButton_Click(object sender, EventArgs e) { try { if (CheckFields()) { return; } var newZamestnanec = new Zamestnanec() { Cislo = cisloText.Text, Cislo_uctu = cislo_ucText.Text, Datum_narodenia = dateTimePicker1.Value, Email = emailText.Text, Heslo = ShaEncrypter.Hash(hesloText.Text), Kod = kodText.Text, Login = loginText.Text, Meno = menoText.Text, Mesto = mestoText.Text, Mobilne_cislo = tel_cisText.Text, Opravnenie = (Opravnenie)(int)comboBox1.SelectedValue, Priezvisko = priezviskoText.Text, Psc = pscText.Text, Rodne_cislo = rod_cisText.Text, Titul = titulText.Text, Ulica = ulicaText.Text }; var data = (HemartContext)_dataManager.GetDbContext(); data.Zamestnanec.Add(newZamestnanec); data.SaveChanges(); Close(); } catch (Exception ex) { MessageBox.Show("Chyba", "Nastala chyba: \n" + ex.Message); } }