//Location methods public void deleteLocation(int id) { using (var db = new DataContext()) { bool dbexist = db.Database.Exists(); if (dbexist == true) { var query = from qlocation in db.location where qlocation.location_id == id select qlocation; foreach (location elocation in query) { elocation.deleted = true; } try { db.SaveChanges(); } catch (Exception e) { Console.WriteLine(e); } } } }
public void delete(int id) { using (var db = new DataContext()) { bool dbexist = db.Database.Exists(); if (dbexist == true) { var query = from qGymnast in db.gymnast where qGymnast.gymnast_id == id select qGymnast; foreach (gymnast eGymnast in query) { eGymnast.deleted = true; } try { db.SaveChanges(); } catch (Exception e) { Console.WriteLine(e); } } } }
public void createVaultKind(vaultkind vaultKind) { using (var db = new DataContext()) { db.vaultkind.Add(vaultKind); try { db.SaveChanges(); } catch (Exception e) { Console.WriteLine(e); } } }
public void create(gymnast gymnast) { using (var db = new DataContext()) { bool dbexist = db.Database.Exists(); if (dbexist == true) { db.gymnast.Add(gymnast); try { db.SaveChanges(); } catch (Exception e) { Console.WriteLine(e); } } } }
public void createVaultnumber(vaultnumber vaultnumber) { using (var db = new DataContext()) { bool dbexist = db.Database.Exists(); if (dbexist == true) { db.vaultnumber.Add(vaultnumber); try { db.SaveChanges(); } catch (Exception e) { Console.WriteLine(e); } } } }
public void create(vault vault) { using (var db = new DataContext()) { bool dbexist = db.Database.Exists(); if (dbexist == true) { if (vault.gymnast != null) { db.gymnast.Attach(vault.gymnast); } if (vault.location != null) { db.location.Attach(vault.location); } if (vault.vaultkind != null) { db.vaultkind.Attach(vault.vaultkind); } if (vault.vaultnumber != null) { db.vaultnumber.Attach(vault.vaultnumber); } db.vault.Add(vault); try { db.SaveChanges(); } catch (Exception e) { Console.WriteLine(e); } } } }
public List<vaultnumber> getVaultNumbers() { using (var db = new DataContext()) { bool dbexist = db.Database.Exists(); if (dbexist == true) { return (from qVaultNumbers in db.vaultnumber where qVaultNumbers.deleted == false select qVaultNumbers ).ToList(); } List<vaultnumber> list = new List<vaultnumber>(); return list; } }
public List<String> getVaultKindNames() { using (var db = new DataContext()) { bool dbexist = db.Database.Exists(); if (dbexist == true) { return (from qVaultKind in db.vaultkind where qVaultKind.deleted == false select qVaultKind.name ).ToList(); } List<String> list = new List<String>(); return list; } }
//Vaultnumber methods public void deleteVaultNumber(int id) { using (var db = new DataContext()) { bool dbexist = db.Database.Exists(); if (dbexist == true) { var query = from qvaultnumber in db.vaultnumber where qvaultnumber.vaultnumber_id == id select qvaultnumber; foreach (vaultnumber evaultnumber in query) { evaultnumber.deleted = true; } try { db.SaveChanges(); } catch (Exception e) { Console.WriteLine(e); } } } }
public List<gymnast> getGymnastCollection() { using (var db = new DataContext()) { bool dbexist = db.Database.Exists(); if (dbexist == true) { return (from qGymnast in db.gymnast where qGymnast.deleted == false select qGymnast ).ToList(); } List<gymnast> list = new List<gymnast>(); return list; } }
public ObservableCollection<vaultkind> readVaultKinds() { ObservableCollection<vaultkind> vaultKinds = new ObservableCollection<vaultkind>(); using (var db = new DataContext()) { var query = from qvaultkind in db.vaultkind where qvaultkind.deleted == false select qvaultkind; foreach (vaultkind vaultKind in query) { vaultKinds.Add(vaultKind); } } return vaultKinds; }
public void update(vault vault) { using (var db = new DataContext()) { bool dbexist = db.Database.Exists(); if (dbexist == true) { var query = (from qVault in db.vault where qVault.vault_id == vault.vault_id select qVault).First(); query.gymnast_id = vault.gymnast_id; query.timestamp = vault.timestamp; query.vault_id = vault.vault_id; query.location_id = vault.location_id; query.vaultkind_id = vault.vaultkind_id; query.vaultnumber_id = vault.vaultnumber_id; query.rating_star = vault.rating_star; query.rating_official_D = vault.rating_official_D; query.rating_official_E = vault.rating_official_E; query.penalty = vault.penalty; try { db.SaveChanges(); } catch (Exception e) { Console.WriteLine(e); } } } }
public void updateVaultnumber(vaultnumber vaultnumber) { if (vaultnumber.vaultnumber_id != 0) { using (var db = new DataContext()) { var query = from qvaultnumber in db.vaultnumber where qvaultnumber.vaultnumber_id == vaultnumber.vaultnumber_id select qvaultnumber; foreach (vaultnumber evaultnumber in query) { evaultnumber.code = vaultnumber.code; evaultnumber.description = vaultnumber.description; evaultnumber.difficulty = vaultnumber.difficulty; evaultnumber.male_female = vaultnumber.male_female; } try { db.SaveChanges(); } catch (Exception e) { Console.WriteLine(e); } } } else { createVaultnumber(vaultnumber); } }
public void updateVaultKind(vaultkind vaultKind) { if (vaultKind.vaultkind_id != 0) { using (var db = new DataContext()) { var query = (from qvaultkind in db.vaultkind where qvaultkind.vaultkind_id == vaultKind.vaultkind_id select qvaultkind).First(); query.name = vaultKind.name; query.description = vaultKind.description; try { db.SaveChanges(); } catch (Exception e) { Console.WriteLine(e); } } } else { createVaultKind(vaultKind); } }
public void updateLocation(location location) { if (location.location_id != 0) { using (var db = new DataContext()) { bool dbexist = db.Database.Exists(); if (dbexist == true) { var query = from qlocation in db.location where qlocation.location_id == location.location_id select qlocation; foreach (location elocation in query) { elocation.name = location.name; elocation.description = location.description; } try { db.SaveChanges(); } catch (Exception e) { Console.WriteLine(e); } } } } else { createLocation(location); } }
public ObservableCollection<vaultnumber> readVaultnumbers() { ObservableCollection<vaultnumber> vaultnumbers = new ObservableCollection<vaultnumber>(); using (var db = new DataContext()) { bool dbexist = db.Database.Exists(); if (dbexist == true) { var query = from qvaultnumber in db.vaultnumber where qvaultnumber.deleted == false select qvaultnumber; foreach (vaultnumber evaultnumber in query) { vaultnumbers.Add(evaultnumber); } } } return vaultnumbers; }
public List<vault> getVaults() { using (var db = new DataContext()) { bool dbexist = db.Database.Exists(); if (dbexist == true) { return (from qVault in db.vault.Include("gymnast").Include("vaultkind").Include("vaultnumber").Include("location") where qVault.deleted == false select qVault ).ToList(); } List<vault> list = new List<vault>(); return list; } }
public gymnast read(int id) { using (var db = new DataContext()) { var query = from gym in db.gymnast where gym.gymnast_id == id select gym; } return null; }
public vault read(int id) { using (var db = new DataContext()) { bool dbexist = db.Database.Exists(); if (dbexist == true) { var query = (from qVault in db.vault.Include("gymnast").Include("vaultnumber").Include("location").Include("vaultkind") where qVault.vault_id == id select qVault).FirstOrDefault(); return query; } vault v = new vault(); return v; } }
public ObservableCollection<location> readLocations() { ObservableCollection<location> locations = new ObservableCollection<location>(); using (var db = new DataContext()) { bool dbexist = db.Database.Exists(); if (dbexist == true) { var query = from qlocation in db.location where qlocation.deleted == false select qlocation; foreach (location elocation in query) { locations.Add(elocation); } } } return locations; }
public Boolean login(string username, string password) { Boolean correctLoginVariables = false; String passwordToHash = password + SALT; byte[] passwordBytes = Encoding.ASCII.GetBytes(passwordToHash); MD5 hasher = MD5.Create(); passwordBytes = hasher.ComputeHash(passwordBytes); StringBuilder sb = new StringBuilder(); for (int i = 0; i < passwordBytes.Length; i++) { sb.Append(passwordBytes[i].ToString("x2")); } String hashedPassword = sb.ToString(); using (var db = new DataContext()) { bool dbexist = db.Database.Exists(); if (dbexist == true) { var query = from qUser in db.user where qUser.username == username && qUser.password == hashedPassword select qUser; foreach (user eUser in query) { if (eUser != null) { _isLoggedIn = true; correctLoginVariables = true; } } } } return correctLoginVariables; }
public void delete(int id) { using (var db = new DataContext()) { bool dbexist = db.Database.Exists(); if (dbexist == true) { var query = (from qVault in db.vault where qVault.vault_id == id select qVault).First(); query.deleted = true; try { db.SaveChanges(); } catch (Exception e) { Console.WriteLine(e); } } } }
public void update(gymnast gymnast) { using (var db = new DataContext()) { bool dbexist = db.Database.Exists(); if (dbexist == true) { var query = from qGymnast in db.gymnast where qGymnast.gymnast_id == gymnast.gymnast_id select qGymnast; foreach (gymnast eGymnast in query) { eGymnast.turnbondID = gymnast.turnbondID; eGymnast.gender = gymnast.gender; eGymnast.nationality = gymnast.nationality; eGymnast.length = gymnast.length; eGymnast.weight = gymnast.weight; eGymnast.picture = gymnast.picture; eGymnast.birthdate = gymnast.birthdate; eGymnast.name = gymnast.name; eGymnast.surname = gymnast.surname; eGymnast.surname_prefix = gymnast.surname_prefix; eGymnast.note = gymnast.note; } try { db.SaveChanges(); } catch (Exception e) { Console.WriteLine(e); } } } }
public List<String> getGymnastNames() { using (var db = new DataContext()) { bool dbexist = db.Database.Exists(); if (dbexist == true) { return (from qGymnast in db.gymnast where qGymnast.deleted == false select qGymnast.name + (qGymnast.surname_prefix.Length > 0 ? " " + qGymnast.surname_prefix : "") + " " + qGymnast.surname ).ToList(); } List<String> list = new List<String>(); return list; } }
public String getLaserData(int id) { using (var db = new DataContext()) { bool dbexist = db.Database.Exists(); if (dbexist == true) { var query = from qVault in db.vault where qVault.vaultnumber_id == id select qVault; String data = String.Empty; foreach (vault eVault in query) { data = eVault.graphdata; } return data; } return " "; } }
public List<location> getLocations() { using (var db = new DataContext()) { bool dbexist = db.Database.Exists(); if (dbexist == true) { return (from qLocation in db.location where qLocation.deleted == false select qLocation ).ToList(); } List<location> list = new List<location>(); return list; } }
public void CheckNetworkConnection() { bool isConnected = false; try { using (var db = new DataContext()) { bool dbexist = db.Database.Exists(); if (dbexist == true) { isConnected = true; } } } catch(Exception e) { isConnected = false; } finally { if (!isConnected) { IsOfflineMode = true; MessageBox.Show("No active network connection could be found.\r\n Some functionalities will not be available", "Not connected to the internet", MessageBoxButton.OK, MessageBoxImage.Warning); } } }
// VaultKind methods public void deleteVaultKind(int id) { using (var db = new DataContext()) { var vaultKind = (from qvaultkind in db.vaultkind where qvaultkind.vaultkind_id == id select qvaultkind).First(); vaultKind.deleted = true; try { db.SaveChanges(); } catch (Exception e) { Console.WriteLine(e); } } }