public ActionResult Edit()
        {
            var            info       = TimeZoneInfo.FindSystemTimeZoneById("W. Central Africa Standard Time");
            DateTimeOffset theOldDate = TimeZoneInfo.ConvertTime(DateTime.Now, info);

            string   stringDate = Convert.ToString(theOldDate);
            DateTime theDate    = Convert.ToDateTime(stringDate);

            // List<PrimarySchoolStudent> theStudents = new List<PrimarySchoolStudent>();
            AttendanceStaffViewModel theStaffAttendace  = new AttendanceStaffViewModel();
            List <AttendanceStaff>   theAttendanceStaff = new List <AttendanceStaff>();
            // // ViewBag.Arm = arm;

            //if (!(string.IsNullOrEmpty(arm)))
            //{
            // List<Attendance> takenAttendance =  work.AttendanceRepository.Get(a => a.DateTaken.Date ==DateTime.Now.Date && a.arm == arm).ToList();
            List <AttendanceStaff> takenAttendanceStaff = work.AttendanceStaffRepository.Get().OrderBy(a => a.DateTaken).ToList();

            takenAttendanceStaff = takenAttendanceStaff.Where(s => s.DateTaken.Date == DateTime.Now.Date).OrderByDescending(a => a.StaffID).ToList();
            if (takenAttendanceStaff.Count() > 0)
            {
                foreach (AttendanceStaff p in takenAttendanceStaff)
                {
                    theAttendanceStaff.Add(new AttendanceStaff()
                    {
                        AttendanceStaffID = p.AttendanceStaffID, DateTaken = p.DateTaken, StaffID = p.StaffID.ToString(), Present = p.Present, NotPresentButTookPermission = p.NotPresentButTookPermission, FirstName = p.FirstName, MiddleName = p.MiddleName, SurName = p.SurName
                    });
                }
                theStaffAttendace.TheAttendanceStaff = theAttendanceStaff;
                return(View("Edit", theStaffAttendace));
                /// return View("Edit", theAttendanceStaff);
            }
            //  ViewBag.Arm = "Attendance for " + arm;
            List <PrimarySchoolStaff> theStaff = work.PrimarySchoolStaffRepository.Get(a => a.UserID != 5000001).ToList();

            foreach (PrimarySchoolStaff p in theStaff)
            {
                theAttendanceStaff.Add(new AttendanceStaff()
                {
                    DateTaken = DateTime.Now, StaffID = p.UserID.ToString(), Present = false, NotPresentButTookPermission = false, FirstName = p.FirstName, MiddleName = p.Middle, SurName = p.LastName
                });
            }
            //  }

            theStaffAttendace.TheAttendanceStaff = theAttendanceStaff;
            return(View("Edit", theStaffAttendace));
        }
        // [Authorize(Roles = "SuperAdmin")]
        public ActionResult Edit(AttendanceStaffViewModel model)
        {
            try
            {
                var            info       = TimeZoneInfo.FindSystemTimeZoneById("W. Central Africa Standard Time");
                DateTimeOffset theOldDate = TimeZoneInfo.ConvertTime(DateTime.Now, info);

                string   stringDate = Convert.ToString(theOldDate);
                DateTime theDate    = Convert.ToDateTime(stringDate);
                //if (!(string.IsNullOrEmpty(attendanceDate)))
                //{
                //    theDate = Convert.ToDateTime(attendanceDate);
                //}
                List <AttendanceStaff> takenAttendanceStaff = work.AttendanceStaffRepository.Get().OrderBy(a => a.DateTaken).ToList();
                takenAttendanceStaff = takenAttendanceStaff.Where(s => s.DateTaken.Date == theDate.Date).OrderByDescending(a => a.StaffID).ToList();
                ////takenAttendanceStaff = takenAttendanceStaff.Where(s => s.DateTaken.Date == DateTime.Now.Date).OrderByDescending(a => a.StaffID).ToList();
                if (takenAttendanceStaff.Count() > 0)
                {
                    //  UnitOfWork work1 = new UnitOfWork();
                    foreach (AttendanceStaff a in model.TheAttendanceStaff)
                    {
                        AttendanceStaff att = work.AttendanceStaffRepository.GetByID(a.AttendanceStaffID);
                        if (att.Present == false && a.Present == true)
                        {
                            a.DateTaken = Convert.ToDateTime(theDate); //DateTime.Now;
                            work1.AttendanceStaffRepository.Update(a);
                        }
                        if (att.NotPresentButTookPermission == false && a.NotPresentButTookPermission == true)
                        {
                            a.DateTaken = theDate; //DateTime.Now;
                            work1.AttendanceStaffRepository.Update(a);
                        }

                        if (att.Present == true && a.Present == false)
                        {
                            a.DateTaken = theDate; //DateTime.Now;
                            work1.AttendanceStaffRepository.Update(a);
                        }
                        if (att.NotPresentButTookPermission == true && a.NotPresentButTookPermission == false)
                        {
                            a.DateTaken = theDate; //DateTime.Now;
                            work1.AttendanceStaffRepository.Update(a);
                        }
                    }
                    work1.Save();
                }
                else
                {
                    foreach (AttendanceStaff a in model.TheAttendanceStaff)
                    {
                        a.DateTaken = DateTime.Now;
                        work.AttendanceStaffRepository.Insert(a);
                    }
                    work.Save();
                }
                if (User.Identity.Name != "5000001")
                {
                    AuditTrail audit = new AuditTrail {
                        Date = DateTime.Now, Action = "Marked Staff Attendance", UserID = User.Identity.Name
                    };
                    work.AuditTrailRepository.Insert(audit);
                    work.Save();
                }


                // TODO: Add update logic here

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }