internal void deleteSubject(Subject sub) { try { using (var db = new DataContext()) { var original = db.Subjects.Find(sub.SubjectID); if (original != null) { db.Subjects.Remove(original); db.SaveChanges(); } } } catch (DbUpdateConcurrencyException) { throw; } catch (DbUpdateException) { MessageBox.Show("You can not delete subject which has realisation.", "Subject Deletion Error"); return; } catch (DbEntityValidationException) { throw; } }
public void deleteSubject(Subject sub) { try { using (var db = new DataContext()) { var original = db.Subjects.Find(sub.SubjectID); if (original != null) { db.Subjects.Remove(original); db.SaveChanges(); } } } catch (DbUpdateConcurrencyException) { throw new EresDataContextException("Blad polaczania z baza danych. Sprobuj jeszcze raz.", "Usuwanie przedmiotu"); } catch (DbUpdateException) { throw new EresDataContextException("Nie mozna usunac przedmiotu z realizacja!", "Usuwanie przedmiotu"); } catch (DbEntityValidationException) { throw new EresDataContextException("Blad polaczania z baza danych.", "Usuwanie przedmiotu"); } }
public void createSubject(string newName, string newConspect, string newUrl) { try { using (var db = new DataContext()) { var subject = new Subject { Name = newName, Conspect = newConspect, url = newUrl }; db.Subjects.Add(subject); db.SaveChanges(); } } catch (DbEntityValidationException) { throw; } }
public void createSubject(string newName, string newConspect, string newUrl) { try { using (var db = new DataContext()) { var subject = new Subject { Name = newName, Conspect = newConspect, url = newUrl }; db.Subjects.Add(subject); db.SaveChanges(); } } catch (DbEntityValidationException) { throw new EresDataContextException("Blad polaczenia z baza danych" ,"Dodawanie przedmiotu"); } }