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 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 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 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); } } } }
//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 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); } }
//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); } } } }
// 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); } } }