public async Task <HttpResponseMessage> GetNews(int userID, int currentIndex, int maxRows) { try { NewsDAL dal = new NewsDAL(); List <NewsInfo> data = await dal.GetNews(userID, currentIndex, maxRows); if (data != null) { return(Request.CreateResponse <List <NewsInfo> >(HttpStatusCode.OK, data)); } else { return(Request.CreateErrorResponse(HttpStatusCode.NotFound, Constants.ErrorNotFound)); } } catch (DbEntityValidationException ex) { var controllerName = ControllerContext.RouteData.Values["controller"].ToString(); var actionName = ControllerContext.RouteData.Values["action"].ToString(); Logger log = new Logger(); log.ErrorLog(ex, controllerName, actionName); return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, Constants.ErrorSysError)); } }
public async Task <HttpResponseMessage> GetStudentDashboard(int userID, int batchID, string role, int currentIndex, int maxRows) { try { MIUEntities db = new MIUEntities(); StudentDashboardInfo data = new StudentDashboardInfo(); EventCalendarDAL dal = new EventCalendarDAL(); NewsDAL newsDAL = new NewsDAL(); ResultDAL resultDAL = new ResultDAL(); AnnouncementDAL announcementDAL = new AnnouncementDAL(); ReportAttendanceDAL reportAttendanceDAL = new ReportAttendanceDAL(); data.EventCalendar = await dal.GetAllEventCalendar(userID, role); data.News = await newsDAL.GetNews(userID, currentIndex, maxRows); string batchCode = db.Batches.Where(x => x.ID == batchID).Select(x => x.BatchCode).SingleOrDefault(); data.StudentDashboard = await resultDAL.GetResult(userID, batchCode); data.Announcement = await announcementDAL.GetLatestAnnouncement(); //data.AttRateAndPercent = await reportAttendanceDAL.GetAttRateAndPercent(batchID, userID); if (data != null) { return(Request.CreateResponse <StudentDashboardInfo>(HttpStatusCode.OK, data)); } else { return(Request.CreateErrorResponse(HttpStatusCode.NotFound, Constants.ErrorNotFound)); } } catch (DbEntityValidationException ex) { var controllerName = ControllerContext.RouteData.Values["controller"].ToString(); var actionName = ControllerContext.RouteData.Values["action"].ToString(); Logger log = new Logger(); log.ErrorLog(ex, controllerName, actionName); return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, Constants.ErrorSysError)); } }
public async Task <HttpResponseMessage> GetLectureDashboard(int accessorID, string role, int courseID = 0) { try { MIUEntities db = new MIUEntities(); LectureDashboardInfo data = new LectureDashboardInfo(); StudentDashboardDAL dal = new StudentDashboardDAL(); NewsDAL newsDAL = new NewsDAL(); ResultDAL resultDAL = new ResultDAL(); AnnouncementDAL announcementDAL = new AnnouncementDAL(); EventCalendarDAL eventDAL = new EventCalendarDAL(); //data.AttRateAndPercent = await reportAttendanceDAL.GetAttRateAndPercent(batchID, userID); data = await dal.GetLectureDashboard(accessorID, courseID); data.Announcement = await announcementDAL.GetLatestAnnouncement(); data.News = newsDAL.GetNews(accessorID, 1, 5).Result; data.EventCalendar = eventDAL.GetAllEventCalendar(accessorID, role).Result; //data.EventCalendar = eventDAL.GetEventCalendar(accessorID, 1, 5).Result; if (data != null) { return(Request.CreateResponse <LectureDashboardInfo>(HttpStatusCode.OK, data)); } else { return(Request.CreateErrorResponse(HttpStatusCode.NotFound, Constants.ErrorNotFound)); } } catch (DbEntityValidationException ex) { var controllerName = ControllerContext.RouteData.Values["controller"].ToString(); var actionName = ControllerContext.RouteData.Values["action"].ToString(); Logger log = new Logger(); log.ErrorLog(ex, controllerName, actionName); return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, Constants.ErrorSysError)); } }
public IEnumerable <News> GetNews() { var instance = new NewsDAL(); return(instance.GetNews()); }