public List <String> AdminsToCmb(string dataObjects) { List <Admins> admins = JsonConvert.DeserializeObject <List <Admins> >(dataObjects); List <String> listek = new List <String>(); for (int x = 0; x < admins.Count; x++) { Admins a = admins[x]; listek.Add(a.name + " " + a.surname); } return(listek); }
public string getWorkerId(string dataObjects, string name, string surname) { List <Admins> admins = JsonConvert.DeserializeObject <List <Admins> >(dataObjects); for (int x = 0; x < admins.Count; x++) { Admins a = admins[x]; if (a.name == name && a.surname == surname) { return(a._id); } } return(""); }
public Boolean logInAdmin(string dataObjects, string email, string password) { List <Admins> admins = JsonConvert.DeserializeObject <List <Admins> >(dataObjects); for (int x = 0; x < admins.Count; x++) { Admins a = admins[x]; if (a.email == email && a.password == password) { Admin_menu am = new Admin_menu(a._id); am.Show(); return(true); } } MessageBox.Show("Napačni email ali pa geslo"); return(false); }
public async void insertAdmin(string name, string sur, string email, string pass) { var admin = new Admins(); admin.name = name; admin.surname = sur; admin.email = email; admin.password = pass; var json = JsonConvert.SerializeObject(admin); var data = new StringContent(json, Encoding.UTF8, "application/json"); var url = $"https://attendance-diary.herokuapp.com/diary/admins"; var client = new HttpClient(); var response = await client.PostAsync(url, data); string result = response.Content.ReadAsStringAsync().Result; Console.WriteLine(result); }