public ActionResult GetRollCallInfo(int RollCallID) { RollCallBusiness RollBO = new RollCallBusiness(); RollCall rollcall = RollBO.GetRollCallByID(RollCallID); AttendanceBusiness AttenBO = new AttendanceBusiness(); var AttendLog = AttenBO.GetRollCallAttendanceLog(RollCallID); var ReturnLog = AttendLog.Where(log => log.LogDate >= DateTime.Today.AddDays(-1)).ToList();//.OrderByDescending(log => log.LogDate); //Truong hop hom nay la thu 2 if (DateTime.Today.DayOfWeek == DayOfWeek.Monday) { //Tim log thu 6 hoac thu 7 DateTime LastSaturday = DateTime.Today.AddDays(-2); var LastSaturdayLog = AttendLog.FirstOrDefault(log => log.LogDate == LastSaturday); if (LastSaturdayLog != null) { ReturnLog.Add(LastSaturdayLog); } else { DateTime LastFriday = DateTime.Today.AddDays(-3); var LastFridayLog = AttendLog.FirstOrDefault(log => log.LogDate == LastFriday); if (LastFridayLog != null) { ReturnLog.Add(LastFridayLog); } } } var RollJson = new { rollID = rollcall.RollCallID, subject = rollcall.Subject.FullName, classes = rollcall.Class.ClassName, time = rollcall.StartTime.ToString(@"hh\:mm") + " - " + rollcall.EndTime.ToString(@"hh\:mm"), date = rollcall.BeginDate.ToString("dd-MM-yyyy") + " to " + rollcall.EndDate.ToString("dd-MM-yyyy"), studentList = rollcall.Students.Select(st => new { studentID = st.StudentID, studentCode = st.StudentCode, studentName = st.FullName, percentRate = String.Format("{0:0.00}%", AttenBO.GetStudentAbsentRate(st.StudentID, RollCallID)) }), logList = ReturnLog.OrderByDescending(log => log.LogDate).Select(log => new { rollID = log.RollCallID, logID = log.LogID, logDate = log.LogDate.ToString("dd-MM-yyyy"), logPresent = log.StudentAttendances.Count(attend => attend.IsPresent) + "/" + log.RollCall.Students.Count, }), }; return(Json(RollJson, JsonRequestBehavior.AllowGet)); }
public ActionResult RollCallDetail(int id) { RollCall RollCall = RollBO.GetRollCallByID(id); //Lay danh sach nhung log cua roll call nay, tu luc bat dau AttendanceBusiness AttenBO = new AttendanceBusiness(); List <AttendanceLog> AttendanceLogs = AttenBO.GetRollCallAttendanceLog(id); RollCallDetailViewModel Model = new RollCallDetailViewModel(); Model.RollCall = RollCall; Model.RollCallLogs = AttendanceLogs; return(View(Model)); }
// GET: /RollCall/Details/5 //view attendance roll call public ViewResult ViewAttendance(int RollCallID) { RollCall RollCall = RollBO.GetRollCallByID(RollCallID); AttendanceBusiness AttendanceBO = new AttendanceBusiness(); //Lay danh sach nhung log cua roll call nay, tu luc bat dau List <AttendanceLog> AttendanceLogs = AttendanceBO.GetRollCallAttendanceLog(RollCallID); RollCallDetailViewModel Model = new RollCallDetailViewModel(); Model.RollCall = RollCall; Model.RollCallLogs = AttendanceLogs; return(View(Model)); }
public ActionResult RollAttendance(int RollCallID, int StudentID) { Student Stu = StuBO.GetStudentByID(StudentID); RollCall Roll = RollBO.GetRollCallByID(RollCallID); AttendanceBusiness AttenBO = new AttendanceBusiness(); List <AttendanceLog> RollCallLogs = AttenBO.GetRollCallAttendanceLog(RollCallID); //Tim nhung attendance cua student, nam trong log, co rollcallID bang RollcallID dua vao var StudentAttendances = Stu.StudentAttendances.Where(sa => sa.AttendanceLog.RollCallID == RollCallID && RollCallLogs.Select(r => r.LogID).Contains(sa.LogID)) .OrderBy(sa => sa.AttendanceLog.LogDate).ToList(); StudentAttendanceViewModel Model = new StudentAttendanceViewModel(); Model.InStudent = Stu; Model.InRollCall = Roll; Model.StudentAttendances = StudentAttendances; return(PartialView("_RollAttendance", Model)); }