public ActionResult CheckAttendanceAuto(int RollCallID, IEnumerable <HttpPostedFileBase> ImageFiles)
        {
            RollCall rollCall = RollBO.GetRollCallByID(RollCallID);

            List <String> ImagePaths = new List <string>();

            foreach (HttpPostedFileBase file in ImageFiles)
            {
                //Save file anh xuong
                String OldPath = Server.MapPath("~/Content/Temp/" + file.FileName);
                file.SaveAs(OldPath);

                //Resize file anh, luu vao thu muc log, ten mon hoc, ten lop
                String NewPath = Server.MapPath("~/Content/Log/"
                                                + rollCall.Class.ClassName + "_"
                                                + rollCall.Subject.ShortName + "_"
                                                + file.FileName);
                FaceBusiness.ResizeImage(OldPath, NewPath);
                ImagePaths.Add(NewPath);
            }
            //Nhan dien tung khuon mat trong anh
            List <RecognizerResult> Result = FaceBusiness.RecognizeStudentForAttendance(RollCallID, ImagePaths);
            //Dua reseult nay cho AttendanceBO xu ly
            AttendanceBusiness AttenBO = new AttendanceBusiness();
            AttendanceLog      Log     = AttenBO.WriteAttendanceAutoLog(RollCallID, Result);


            //Danh sach sinh vien trong log
            StudentBusiness StuBO    = new StudentBusiness();
            List <Student>  Students = StuBO.Find(stu => stu.StudentAttendances.
                                                  Any(attend => attend.LogID == Log.LogID && attend.IsPresent)).ToList();
            RollCall CurrentRollCall = RollBO.GetRollCallByID(RollCallID);

            //Tao model de show trong view
            AttendanceViewModel model = new AttendanceViewModel();

            model.CurrentRollCall = CurrentRollCall;
            model.PresentStudents = Students;
            model.RecognizeResult = Result;

            return(View(model));
        }
        public ActionResult CheckAttendanceAuto(int RollCallID, List <HttpPostedFileBase> ImageFiles, DateTime?AttendanceDate)
        {
            RollCallBusiness RollBO  = new RollCallBusiness();
            var           rollCall   = RollBO.GetRollCallByID(RollCallID);
            List <String> ImagePaths = new List <string>();

            foreach (HttpPostedFileBase file in ImageFiles)
            {
                //Save file anh xuong
                String OldPath = Server.MapPath("~/Content/Temp/" + file.FileName);
                file.SaveAs(OldPath);

                //Resize file anh, luu vao thu muc log, nho them ngay thang truoc
                String NewPath = Server.MapPath("~/Content/Log/"
                                                + rollCall.Class.ClassName + "_"
                                                + rollCall.Subject.ShortName + "_"
                                                + file.FileName);
                FaceBusiness.ResizeImage(OldPath, NewPath);
                ImagePaths.Add(NewPath);

                //Nhan dien tung khuon mat trong anh
            }

            List <RecognizerResult> Results = FaceBusiness.RecognizeStudentForAttendance(RollCallID, ImagePaths);
            //Dua result nay cho AttendanceBO xu ly
            AttendanceBusiness AttenBO = new AttendanceBusiness();
            AttendanceLog      Log     = null;

            if (AttendanceDate == null)
            {
                Log = AttenBO.WriteAttendanceAutoLog(RollCallID, Results);
            }
            else
            {
                Log = AttenBO.WriteAttendanceAutoLog(RollCallID, Results, AttendanceDate.Value);
            }

            //Danh sach sinh vien trong log

            List <int> StudentIDs = AttenBO.GetStudentIDList(Results);

            //Lay danh sach sinh vien ton tai trong log
            StudentBusiness StuBO = new StudentBusiness();
            //List<Student> Students = StuBO.Find(stu => StudentIDs.Contains(stu.StudentID)).ToList();

            /*
             * var StudentsJson = Students.ToList().Select(s => new
             * {
             *  studentID = s.StudentID,
             *  studentCode = s.StudentCode,
             *  studentName = s.FullName
             * });
             */

            var StudentsJson = Log.StudentAttendances.Select(sa => new
            {
                studentID   = sa.StudentID,
                studentCode = sa.Student.StudentCode,
                studentName = sa.Student.FullName,
                isPresent   = sa.IsPresent
            });

            return(Json(StudentsJson, JsonRequestBehavior.AllowGet));
        }