public JsonResult GetAbsentRecord(string level, string course) { try { if (string.IsNullOrEmpty(level) && string.IsNullOrEmpty(course)) { return(null); } AbsentLogLogic absentLogLogic = new AbsentLogLogic(); List <AbsentLogModel> absentLogs = new List <AbsentLogModel>(); LEVEL levelentity = new LEVEL { Id = Convert.ToInt32(level) }; COURSE courseentity = new COURSE() { Id = Convert.ToInt32(course) }; absentLogs = absentLogLogic.GetBy(levelentity, courseentity); return(Json(absentLogs, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { throw; } return(null); }
public ActionResult ViewAttendance(string eventId) { _viewModel = new EventViewModel(); try { if (!string.IsNullOrEmpty(eventId)) { long myEventId = Convert.ToInt64(Utility.Decrypt(eventId)); AttendanceLogic attendanceLogic = new AttendanceLogic(); AbsentLogLogic absentLogLogic = new AbsentLogLogic(); _viewModel.AttendanceList = attendanceLogic.GetEntitiesBy(s => s.Event_Id == myEventId); _viewModel.AttendanceList.ForEach(e => { if (e.Attendance_Status_Id == (int)AttendanceStatuses.Excused) { e.ATTENDANCE_STATUS.Name = absentLogLogic.GetAbsenceRequestStatus(e); } }); _viewModel.EventId = myEventId; } } catch (Exception ex) { SetMessage("Error! " + ex.Message, Message.Category.Error); } return(View(_viewModel)); }
public AttendanceController() { _studentLogic = new StudentLogic(); _eventLogic = new EventLogic(); _absentTypeLogic = new AbsentTypeLogic(); _attendanceLogic = new AttendanceLogic(); _absentLogLogic = new AbsentLogLogic(); _courseLogic = new CourseLogic(); }
public JsonResult DeleteEvent(long eventId) { JsonResponseModel result = new JsonResponseModel(); try { if (eventId > 0) { AbsentLogLogic logLogic = new AbsentLogLogic(); EventLogic eventLogic = new EventLogic(); AttendanceLogic attendanceLogic = new AttendanceLogic(); ABSENT_LOG eventLog = logLogic.GetEntitiesBy(e => e.Event_Id == eventId).LastOrDefault(); ATTENDANCE eventAttendance = attendanceLogic.GetEntitiesBy(e => e.Event_Id == eventId).LastOrDefault(); if (eventLog == null && eventAttendance == null) { eventLogic.Delete(c => c.Id == eventId); result.IsError = false; result.Message = "Operation Successful!"; } else { result.IsError = true; result.Message = "Event is already attached to an attendance / absent log"; } } else { result.IsError = true; result.Message = "Invalid parameter"; } } catch (Exception ex) { result.IsError = true; result.Message = ex.Message; } return(Json(result, JsonRequestBehavior.AllowGet)); }
public JsonResult UpdateAbsentlog(string updateArray) { JsonResponseModel model = new JsonResponseModel(); try { int modifiedCount = 0; if (string.IsNullOrEmpty(updateArray)) { return(null); } List <AbsentLogModel> absentLogModels = JsonConvert.DeserializeObject <List <AbsentLogModel> >(updateArray); AbsentLogLogic absentLogLogic = new AbsentLogLogic(); UserLogic userLogic = new UserLogic(); USER user = userLogic.GetEntityBy(u => u.Username == User.Identity.Name); for (int i = 0; i < absentLogModels.Count; i++) { long id = absentLogModels[i].Id; ABSENT_LOG absentLog = absentLogLogic.GetEntityBy(a => a.Id == id); if (absentLog != null) { if (absentLogModels[i].Accept) { absentLog.Approved = absentLogModels[i].Accept; } if (absentLogModels[i].Decline) { absentLog.Approved = !absentLogModels[i].Decline; absentLog.Reject_Reason = absentLogModels[i].RejectReason; absentLog.Remark = absentLogModels[i].Remark; } absentLog.User_Id = user.Id; var modified = absentLogLogic.Modify(absentLog); if (modified) { modifiedCount += 1; } } } if (modifiedCount > 0) { model.IsError = false; model.Message = "Operation Successful"; } else { model.IsError = true; model.Message = "Nothing found to be Updated"; } } catch (Exception ex) { model.IsError = true; model.Message = ex.Message + "Operation Failed"; } return(Json(model, JsonRequestBehavior.AllowGet)); }
public ActionResult DownloadAttendance(string eventId) { _viewModel = new EventViewModel(); try { if (!string.IsNullOrEmpty(eventId)) { long myEventId = Convert.ToInt64(Utility.Decrypt(eventId)); AttendanceLogic attendanceLogic = new AttendanceLogic(); AbsentLogLogic absentLogLogic = new AbsentLogLogic(); _viewModel.AttendanceList = attendanceLogic.GetEntitiesBy(s => s.Event_Id == myEventId); _viewModel.AttendanceList.ForEach(e => { if (e.Attendance_Status_Id == (int)AttendanceStatuses.Excused) { e.ATTENDANCE_STATUS.Name = absentLogLogic.GetAbsenceRequestStatus(e); } }); GridView gv = new GridView(); DataTable ds = new DataTable(); if (_viewModel.AttendanceList.Count > 0) { List <ATTENDANCE> list = _viewModel.AttendanceList.OrderBy(p => p.STUDENT.Matric_Number).ToList(); List <AttendanceModel> sort = new List <AttendanceModel>(); for (int i = 0; i < list.Count; i++) { AttendanceModel attendance = new AttendanceModel(); attendance.SN = (i + 1); attendance.Name = list[i].STUDENT.PERSON.Last_Name + " " + list[i].STUDENT.PERSON.First_Name + " " + list[i].STUDENT.PERSON.Other_Name; attendance.Registration_Number = list[i].STUDENT.Matric_Number; attendance.Event_Type = list[i].EVENT.EVENT_TYPE.Name; if (list[i].EVENT.COURSE != null) { attendance.Course_Hall = list[i].EVENT.COURSE.Name; } else if (list[i].EVENT.HALL != null) { attendance.Course_Hall = list[i].EVENT.HALL.Name; } else { attendance.Course_Hall = ""; } attendance.Location = list[i].EVENT.LOCATION.Name; attendance.Date = list[i].EVENT.Date.ToLongDateString(); attendance.Time_Taken = list[i].Time_Taken.ToLongTimeString(); attendance.Status = list[i].ATTENDANCE_STATUS.Name; sort.Add(attendance); } gv.DataSource = sort; string caption = "Attendnace Report"; if (list != null && list.Count > 0) { caption = "Attendnace Report for " + list.FirstOrDefault().EVENT.DEPARTMENT.Name + ". " + list.FirstOrDefault().EVENT.LEVEL.Name + ". Session: " + list.FirstOrDefault().EVENT.SESSION.Name; } gv.Caption = caption.ToUpper(); gv.DataBind(); string filename = caption.Replace("\\", "") + ".xls"; return(new DownloadFileActionResult(gv, filename)); } else { Response.Write("No data available for download"); Response.End(); return(new JavaScriptResult()); } } } catch (Exception ex) { SetMessage("Error! " + ex.Message, Message.Category.Error); } return(RedirectToAction("ViewAttendance", "Event", new { Area = "Admin", eventId = eventId })); }