public void Create(University university) { using (var db = new LibraryTestContext()) { db.Universities.Add(university); db.SaveChanges(); } }
public void DeleteUniversity(int id) { using (var db = new LibraryTestContext()) { var university = db.Universities.Where(t => t.UniversityId == id).FirstOrDefault(); db.Entry(university).State = System.Data.Entity.EntityState.Deleted; db.SaveChanges(); } }
public void UpdateUniversity(University updatedUniversity) { using (var db = new LibraryTestContext()) { var university = db.Universities.Where(t => t.UniversityId == updatedUniversity.UniversityId).FirstOrDefault(); if (university != null) { university.Name = updatedUniversity.Name; university.Address = updatedUniversity.Address; db.SaveChanges(); } } }
public void Create(Library library) { db.Libraries.Add(library); db.SaveChanges(); }
public void CreateBook([FromBody] Book book) { db.Books.Add(book); db.SaveChanges(); }
public void CreateStudent(Student student) { db.Students.Add(student); db.SaveChanges(); }