public ActionResult TakeAttendance(HttpPostedFileBase zip, HttpPostedFileBase img, FormCollection collector)
        {
            #region Declaring Varibles

            string path = Server.MapPath("~/Uploads/TrainingSet/");
            string haarcascades = HttpContext.Server.MapPath("~/haarcascades/haarcascade_frontalface_default.xml");
            string theePath = "";
            BusinessLogicHandler _gateWay;
            Lecture _mod;
            List<string> User_Id;

            #endregion

            #region getting the modulecode

            _gateWay = new BusinessLogicHandler();
            _mod = new Lecture();
            _mod = _gateWay.GetLecture(Convert.ToInt32(collector.GetValue("Lecture").AttemptedValue));

            #endregion

            #region Checking or Creating the directory

            string newPath = Server.MapPath("~/Uploads/Attendance/");
            if (Directory.Exists(newPath))
            {
                if (Directory.Exists(newPath + _mod.ModuleCode))
                {
                    theePath = newPath + _mod.ModuleCode.Trim() + "/" + _mod.VenueCode.Trim() + "/" + DateTime.Today.ToString("ddMMMMyyyy");
                    if (!Directory.Exists(theePath))
                        Directory.CreateDirectory(theePath);
                }
                else
                {
                    Directory.CreateDirectory(newPath + _mod.ModuleCode);
                    theePath = newPath + _mod.ModuleCode.Trim() + "/" + _mod.VenueCode.Trim() + "/" + DateTime.Today.ToString("ddMMMMyyyy");
                    if (!Directory.Exists(theePath))
                        Directory.CreateDirectory(theePath);
                }
            }
            else
            { Directory.CreateDirectory(newPath); }
            string imgPath = "~/Uploads/Attendance/" + _mod.ModuleCode.Trim() + "/" + _mod.VenueCode.Trim() + "/" + DateTime.Today.ToString("ddMMMMyyyy");

            #endregion

            #region Image not null 
            if (img != null && zip == null)
            {
                User_Id = new List<string>();
                Bitmap _Img = new Bitmap(img.InputStream);

                #region processing the img

                CoreSysFunction _coreFunction = new CoreSysFunction();
                User_Id.AddRange(_coreFunction.DetectAndRecognize(_Img, path, haarcascades));
                Bitmap toSave = _coreFunction.IdentifyAndMark(haarcascades, _Img);
                toSave.Save(theePath +"/"+ _mod.VenueCode.Trim()+".jpg", System.Drawing.Imaging.ImageFormat.Jpeg);
                imgPath += "/" + _mod.VenueCode.Trim() + ".jpg";
                #endregion

                #region object to view page

                Bridge _bridge = new Bridge();
                _bridge.filePath = new List<string>();
                _bridge.filePath.Add( imgPath);
                _bridge.User_Id = new List<string>();
                _bridge.User_Id = User_Id;
                _bridge.dateSlice = collector.GetValue("dateHoldhidden").AttemptedValue.Split(' ');
                _bridge.Lecture_Id = Convert.ToInt32(collector.GetValue("Lecture").AttemptedValue);
                Session["Data"] = _bridge;

                #endregion

                return RedirectToActionPermanent("ViewAttendees");
            }
            #endregion

            #region Image not null and zip not null
            else if (zip != null && img != null)
            {
                User_Id = new List<string>();
                Bridge _bridge = new Bridge();
                List<string> fileNames = new List<string>();
                _bridge.filePath = new List<string>();
                Bitmap _Img = new Bitmap(img.InputStream);

                #region processing the img

                CoreSysFunction _coreFunction = new CoreSysFunction();
                User_Id.AddRange(_coreFunction.DetectAndRecognize(_Img, path, haarcascades));
                Bitmap toSave = _coreFunction.IdentifyAndMark(haarcascades, _Img);
                toSave.Save(theePath + "/" + _mod.VenueCode.Trim() + ".jpg", System.Drawing.Imaging.ImageFormat.Jpeg);
                _bridge.filePath.Add(imgPath +"/" + _mod.VenueCode.Trim() + ".jpg");
                #endregion

                #region Processing zip
                Stream zipStream = zip.InputStream;
                using (var _img = ZipFile.Read(zipStream))
                {
                    foreach (var file in _img.Entries)
                    {
                        file.Extract(theePath, ExtractExistingFileAction.OverwriteSilently);
                        Image bmp = Image.FromFile(theePath + "/" + file.FileName);
                        Bitmap mbmp = new Bitmap(bmp);
                        fileNames.Add(theePath + "/" + file.FileName);
                        User_Id.AddRange(_coreFunction.DetectAndRecognize(mbmp, path, haarcascades));
                        toSave = _coreFunction.IdentifyAndMark(haarcascades, mbmp);
                        try { toSave.Save(imgPath + "/" + file.FileName); _bridge.filePath.Add(imgPath += "/" + file.FileName); }
                        catch (Exception e) {  }
                        
                    }
                }
                #endregion

                #region object to view
                _bridge.User_Id = new List<string>();
                _bridge.User_Id = User_Id.Distinct();
                _bridge.dateSlice = collector.GetValue("dateHoldhidden").AttemptedValue.Split(' ');
                _bridge.Lecture_Id = Convert.ToInt32(collector.GetValue("Lecture").AttemptedValue);
                Session["Data"] = _bridge;

                #endregion

                return RedirectToActionPermanent("ViewAttendees");
            }
            #endregion

            #region Zip not null
            else if (zip != null)
            {
                return RedirectToActionPermanent("ViewAttendees");
            }
            #endregion

            else
            { return RedirectToActionPermanent("Index"); }
        }
        public ActionResult ViewAttendees()
        {
            #region Declaring the variables

            BusinessLogicHandler _gateWay = new BusinessLogicHandler();
            List<Student> _studList = new List<Student>();
            Student _student = new Student();
            Lecturer _lecturer = new Lecturer();
            Lecture _lecture = new Lecture();
            CloserViewModel _closer = new CloserViewModel();

            #endregion

            Bridge _bridge = (Bridge)Session["Data"];
            //_lecture = _gateWay.GetLecture(_bridge.Lecture_Id);

            #region Getting The students

            foreach (var item in _bridge.User_Id)
            {
                string[] exString = item.Split('.');
                _student = _gateWay.GetStudent(exString[0]);
                _student.User_Id = item.ToString();
                _studList.Add(_student);
            }
            _closer.Students = _studList;

            #endregion

            #region Getting the lecture details

            _lecture = _gateWay.GetLecture(_bridge.Lecture_Id);
            _closer.Lecture = _lecture;

            #endregion

            #region Setting the date

            _closer.Date = "";
            for (int x = 0; x < 4; x++)
            {
                _closer.Date += _bridge.dateSlice[x] + " ";
            }

            #endregion

            #region Getting Lecturer details

            _lecturer = _gateWay.GetLecturer_StuffNumber(_lecture.StaffNumber);
            _closer.Lecturer = new Lecturer();
            _closer.Lecturer = _lecturer;
            #endregion

            #region Assigning images
            if (_bridge.filePath != null)
                _closer.files = _bridge.filePath;
            #endregion

            return View(_closer);
        }
 public ActionResult Details(string selectedValue)
 {
     AttendanceViewModel _model = new AttendanceViewModel();
     BusinessLogicHandler _gateWay = new BusinessLogicHandler();
     _model.Lecture = new Lecture();
     _model.Lecture = _gateWay.GetLecture(int.Parse(selectedValue));
     object[] response = { _model.Lecture.ModuleCode, _model.Lecture.VenueCode, _model.Lecture.TimeSlot };
     return Json(response);
 }