public ActionResult Create([Bind(Include = "CheckIn_Id,StudId,ResId,ResName,Date_In,RoomId")] StudentCheckIn studentCheckIn)
        {
            DateTime now = DateTime.UtcNow;

            var userId   = User.Identity.GetUserId();
            var username = User.Identity.GetUserName();

            Guid   guid = new Guid();
            Random r    = new Random();

            if (ModelState.IsValid)
            {
                if (studentCheckIn.CheckStudent() == true)
                {
                    if (studentCheckIn.checkRoomStatus() == true)
                    {
                        var student = db.Students.ToList().Find(x => x.Email == User.Identity.GetUserName());
                        studentCheckIn.StudId = student.StudId;
                        var resid = lo.getStudentRes((student.IdNumber));
                        if (lo.canCheckIn(student.Email, studentCheckIn.RooNumber) == false)
                        {
                            TempData["message"] = "Cannot checkin into a " + lo.getGender(studentCheckIn.RooNumber) + "'s room.";
                            return(RedirectToAction("Create"));
                        }
                        if (studentCheckIn.CheckRoomGender(username) == false)
                        {
                            TempData["message"] = "Cannot checkin into a " + lo.getGender(studentCheckIn.RooNumber) + "'s room.";

                            return(RedirectToAction("Create"));
                        }

                        studentCheckIn.ResId = resid;

                        // studentCheckIn.UpdateCheckIn();
                        var qtyUpdate = db.ResAvailabilities.Where(x => x.ResId == resid).FirstOrDefault();
                        qtyUpdate.CheckedIN      += 1;
                        db.Entry(qtyUpdate).State = System.Data.Entity.EntityState.Modified;
                        studentCheckIn.UpdateStatus();
                        studentCheckIn.CheckIn_Id = guid.ToString() + r.Next(2, 10000).ToString();
                        studentCheckIn.ResName    = lo.getResName(studentCheckIn.getStudentNUmber());
                        studentCheckIn.Date_In    = now.Date;
                        studentCheckIn.RooNumber  = studentCheckIn.GetRoomNumber();
                        //studentCheckIn.RoomId=studentCheckIn.RoomId
                        studentCheckIn.UpdateProfile();
                        studentCheckIn.updateSpace();
                        Bs.AddStudentCheckIn(studentCheckIn);
                        db.SaveChanges();

                        return(RedirectToAction("Create", "PDFs"));
                    }
                    else
                    {
                        ModelState.AddModelError("", "Room is Already Taken");
                    }
                }
                else
                {
                    ModelState.AddModelError("", "Student is already checked in");
                }
            }

            ViewBag.ResId  = new SelectList(db.Residences, "ResId", "ResName", studentCheckIn.ResId);
            ViewBag.RoomId = new SelectList(db.Rooms.Where(x => x.Space != 0 && x.Residence.ResId == studentCheckIn.ResId), "RoomId", "RoomNumber", studentCheckIn.RoomId);
            if (User.IsInRole("SystemAdmin"))
            {
                ViewBag.StudId = new SelectList(db.Students, "StudId", "StudentNumber", studentCheckIn.StudId);
            }
            else if (User.IsInRole("Student"))
            {
                ViewBag.StudId = new SelectList(db.Students.Where(x => x.Email == userId), "StudId", "StudentNumber", studentCheckIn.StudId);
            }
            return(View(studentCheckIn));
        }