Exemple #1
0
 internal static Rooms LookForRoom(int schoolID, int roomID)
 {
     using (schoolEntities dbContext = new schoolEntities())
     {
         return(dbContext.Rooms.FirstOrDefault(f => f.SchoolId == schoolID && f.Id == roomID));
     }
 }
Exemple #2
0
 internal static Rooms LookForRoom(int schoolID, string roomName)
 {
     using (schoolEntities dbContext = new schoolEntities())
     {
         return(dbContext.Rooms.FirstOrDefault(f => f.SchoolId == schoolID && f.Number == roomName));
     }
 }
Exemple #3
0
 // 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));
     }
 }
Exemple #4
0
 // 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;
 }
Exemple #6
0
        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));
    }
Exemple #8
0
 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());
     }
 }
Exemple #9
0
 // 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);
     }
 }
Exemple #10
0
 // 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());
     }
 }
Exemple #11
0
 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());
     }
 }
Exemple #12
0
 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());
     }
 }
Exemple #13
0
 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());
     }
 }
Exemple #14
0
 // 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());
     }
 }
Exemple #15
0
 // 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());
     }
 }
Exemple #16
0
 // 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());
     }
 }