Exemple #1
0
        public ActionResult DeleteConfirmed(int id)
        {
            RoomStudent roomStudent = Bs.GetTRoomStudent(id);

            Bs.RemoveRoomStudent(roomStudent);
            return(RedirectToAction("Index"));
        }
Exemple #2
0
 public ActionResult Edit([Bind(Include = "RStudentId,StudId,RoomId,Date_Assigned")] RoomStudent roomStudent)
 {
     if (ModelState.IsValid)
     {
         Bs.UpdateRoomStudent(roomStudent);
         return(RedirectToAction("Index"));
     }
     ViewBag.RoomId = new SelectList(db.Rooms, "RoomId", "RoomNumber", roomStudent.RoomId);
     ViewBag.StudId = new SelectList(db.Students, "StudId", "Name", roomStudent.StudId);
     return(View(roomStudent));
 }
Exemple #3
0
 public bool RemoveRoomStudent(RoomStudent roomStudent)
 {
     try
     {
         db.RoomStudents.Remove(roomStudent);
         db.SaveChanges();
         return(true);
     }
     catch (Exception ex)
     { return(false); }
 }
Exemple #4
0
 public bool UpdateRoomStudent(RoomStudent roomStudent)
 {
     try
     {
         db.Entry(roomStudent).State = EntityState.Modified;
         db.SaveChanges();
         return(true);
     }
     catch (Exception ex)
     { return(false); }
 }
Exemple #5
0
        // GET: RoomStudents/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            RoomStudent roomStudent = db.RoomStudents.Find(id);

            if (roomStudent == null)
            {
                return(HttpNotFound());
            }
            return(View(roomStudent));
        }
Exemple #6
0
        // GET: RoomStudents/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            RoomStudent roomStudent = Bs.GetTRoomStudent(id);

            if (roomStudent == null)
            {
                return(HttpNotFound());
            }
            return(View(roomStudent));
        }
Exemple #7
0
        // GET: RoomStudents/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            RoomStudent roomStudent = db.RoomStudents.Find(id);

            if (roomStudent == null)
            {
                return(HttpNotFound());
            }
            ViewBag.RoomId = new SelectList(db.Rooms, "RoomId", "RoomNumber", roomStudent.RoomId);
            ViewBag.StudId = new SelectList(db.Students, "StudId", "Name", roomStudent.StudId);
            return(View(roomStudent));
        }
Exemple #8
0
        public ActionResult Create([Bind(Include = "RStudentId,StudId,RoomId,Date_Assigned,em")] RoomStudent roomStudent)
        {
            if (ModelState.IsValid)

            {
                roomStudent.em = User.Identity.GetUserName();
                if (roomStudent.CheckStudent(roomStudent.StudId) == true)
                {
                    roomStudent.updateSpace();
                    roomStudent.checkAvailabilty();

                    roomStudent.Date_Assigned = DateTime.Now.Date;
                    if (roomStudent.checkAvailabilty() == true)
                    {
                        roomStudent.UpdateStatus();
                        Bs.AddRoomStudent(roomStudent);
                        return(RedirectToAction("Index"));
                    }
                    else
                    {
                        ModelState.AddModelError("", "Room Is Already Taken");
                    }
                }

                else
                {
                    ModelState.AddModelError("", "Student  Is Already Assigned To Room");
                }
            }

            var UserId = User.Identity.GetUserId();

            ViewBag.RoomId = new SelectList(db.Rooms.Where(x => x.Status != "Taken"), "RoomId", "RoomNumber", roomStudent.RoomId);
            if (User.IsInRole("SystemAdmin"))
            {
                ViewBag.StudId = new SelectList(db.Students, "StudId", "Name", roomStudent.StudId);
            }
            else
            {
                ViewBag.StudId = new SelectList(db.Students.Where(x => x.Email == UserId), "StudId", "Name", roomStudent.StudId);
            }
            return(View(roomStudent));
        }
Exemple #9
0
 private void UpdateRoomStudents(Session session, Room room, Exam exam1, List <Student> stud1, int capacity)
 {
     for (int i = 0; i < capacity; i++)
     {
         RoomStudent temp = new RoomStudent
         {
             Exam    = exam1,
             Session = session,
             Student = stud1.First(),
             Room    = room
         };
         room.RoomStudents.Add(temp);
         if (room.Exams.Contains(exam1) == false)
         {
             room.Exams.Add(exam1);
         }
         db.SaveChanges();
         stud1.Remove(stud1.First());
     }
 }