public void deleteRegistration(Registration r) { try { using (var db = new DataContext()) { var orig = db.Registrations.Find(r.RegistrationID); if (orig != null) { db.Registrations.Remove(orig); db.SaveChanges(); } } } catch (DbUpdateConcurrencyException) { throw; } catch (DbUpdateException) { MessageBox.Show("You can not delete used registartion.", "Registration Deletion Error"); return; } catch (DbEntityValidationException) { throw; } }
public void deleteRegistration(Registration r) { try { using (var db = new DataContext()) { var orig = db.Registrations.Find(r.RegistrationID); if (orig != null) { db.Registrations.Remove(orig); db.SaveChanges(); } } } catch (DbUpdateConcurrencyException) { throw new EresDataContextException("Blad polaczania z baza danych. Sprobuj jeszcze raz.", "Usuwanie rejestracji"); } catch (DbUpdateException) { throw new EresDataContextException("Nie mozna usunac trwajacej rejestracji!", "Usuwanie rejestracji"); } catch (DbEntityValidationException) { throw new EresDataContextException("Blad polaczania z baza danych.", "Usuwanie rejestracji"); } }
public void createRegistration(int realId, int studId) { try { using (var db = new DataContext()) { var real = db.Realisations.Find(realId); var stud = db.Students.Find(studId); var reg = new Registration { Realisation = real, Student = stud }; db.Registrations.Add(reg); db.SaveChanges(); } } catch (DbEntityValidationException) { throw; } }
public void createRegistration(int realId, int studId) { try { using (var db = new DataContext()) { var real = db.Realisations.Find(realId); var stud = db.Students.Find(studId); var reg = new Registration { Realisation = real, Student = stud }; db.Registrations.Add(reg); db.SaveChanges(); } } catch (DbEntityValidationException) { throw new EresDataContextException("Blad polaczania z baza danych.", "Dodawanie rejestracji"); } }