internal static Rooms LookForRoom(int schoolID, int roomID) { using (schoolEntities dbContext = new schoolEntities()) { return(dbContext.Rooms.FirstOrDefault(f => f.SchoolId == schoolID && f.Id == roomID)); } }
internal static Rooms LookForRoom(int schoolID, string roomName) { using (schoolEntities dbContext = new schoolEntities()) { return(dbContext.Rooms.FirstOrDefault(f => f.SchoolId == schoolID && f.Number == roomName)); } }
// Method to get a school by Name, using entity internal static Schools GetSchoolByName(string name) { using (schoolEntities dbContext = new schoolEntities()) { return(dbContext.Schools.FirstOrDefault(f => f.Name == name)); } }
// Method to get a school by ID, using entity internal static Schools GetSchoolByID(int id) { using (schoolEntities dbContext = new schoolEntities()) { return(dbContext.Schools.FirstOrDefault(f => f.Id == id)); } }
public StudentP(schoolEntities db, Students st) { _db = db; InitializeComponent(); Mystudent = st; DataContext = this; }
private void edit_Click(object sender, RoutedEventArgs e) { var item = StudentsData.SelectedItem as Students; var db = new schoolEntities(); var st = db.Students.Where(s => s.id == item.id).First(); NavigationService.Navigate(new StudentP(db, st)); }
ActionResult GetViewWithGrid(int pageSize) { schoolEntities db = new schoolEntities(); List <Student> result = db.Students.ToList(); //ViewBag.pageSize = int.Parse(pagesizelist.SelectedValue); ViewBag.pageSize = pageSize; return(View(viewNameWithGrid, result)); }
internal static int DeleteAllRoomsInSchool(int schoolID) { using (schoolEntities dbContext = new schoolEntities()) { dbContext.Rooms.RemoveRange(dbContext.Rooms.Where(f => f.SchoolId == schoolID)); dbContext.SaveChanges(); return(dbContext.SaveChanges()); } }
// Method to check if a school has rooms internal static bool SchoolHadRooms(Schools deletingSchool) { using (schoolEntities dbContext = new schoolEntities()) { Rooms deletedRooms = new Rooms(); deletedRooms = dbContext.Rooms.FirstOrDefault(f => f.SchoolId == deletingSchool.Id); return(deletedRooms != null); } }
// Method to modify a school name internal static int ModifySchoolName(int id, string newName) { using (schoolEntities dbContext = new schoolEntities()) { Schools renamedSchool = dbContext.Schools.FirstOrDefault(f => f.Id == id); renamedSchool.Name = newName; return(dbContext.SaveChanges()); } }
internal static int DeleteRoomByName(int schoolID, string roomName) { using (schoolEntities dbContext = new schoolEntities()) { Rooms roomToDelete; roomToDelete = dbContext.Rooms.FirstOrDefault(f => f.SchoolId == schoolID && f.Number == roomName); dbContext.Rooms.Remove(roomToDelete); return(dbContext.SaveChanges()); } }
internal static int ModifyRoomName(int schoolID, int roomID, string newRoomName) { using (schoolEntities dbContext = new schoolEntities()) { Rooms roomToRename; roomToRename = dbContext.Rooms.FirstOrDefault(f => f.SchoolId == schoolID && f.Id == roomID); roomToRename.Number = newRoomName; return(dbContext.SaveChanges()); } }
internal static int InsertRoom(int schoolID, string roomName) { using (schoolEntities dbContext = new schoolEntities()) { dbContext.Rooms.Add(new Rooms { SchoolId = schoolID, Number = roomName }); return(dbContext.SaveChanges()); } }
// Method to delete a school by Name internal static int DeleteSchool(string name) { using (schoolEntities dbContext = new schoolEntities()) { Schools deletedSchool = new Schools(); deletedSchool = dbContext.Schools.FirstOrDefault(f => f.Name == name); dbContext.Schools.Remove(deletedSchool); return(dbContext.SaveChanges()); } }
// Method to delete a school by ID internal static int DeleteSchool(int id) { using (schoolEntities dbContext = new schoolEntities()) { Schools deletedSchool; deletedSchool = dbContext.Schools.FirstOrDefault(f => f.Id == id); dbContext.Schools.Remove(deletedSchool); return(dbContext.SaveChanges()); } }
// Method to insert a school in DB internal static int InsertSchool(string name) { using (schoolEntities dbContext = new schoolEntities()) { dbContext.Schools.Add(new Schools { Name = name }); return(dbContext.SaveChanges()); } }