Ejemplo n.º 1
0
        /// <summary>
        /// Method to allot students to a room in the current allotment
        /// </summary>
        /// <param name="db">The database</param>
        private void AllotStudentsToRoom(ExamRoomAllocationEntities db)
        {
            List <Student> students = db.Students
                                      .Where(x => x.Exams.Where(y => y.Id == Exam.Id).Count() != 0 &&
                                             x.RoomStudents.Where(y => y.exam_id == Exam.Id).Count() == 0)
                                      .OrderBy(x => x.DepartmentId)
                                      .Take(NumberOfStudents)
                                      .ToList();

            foreach (var student in students)
            {
                db.RoomStudents.Add(new RoomStudent
                {
                    Room_Id    = Room.Id,
                    Student_Id = student.Id,
                    Session_Id = Exam.SessionId,
                    exam_id    = Exam.Id
                });
            }
            db.SaveChanges();
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Method to add the exam to the room
 /// </summary>
 /// <param name="db">The database</param>
 private void AllotExamToRoom(ExamRoomAllocationEntities db)
 {
     Room.Exams.Add(Exam);
     db.Entry(Exam).State = System.Data.Entity.EntityState.Modified;
     db.SaveChanges();
 }