Example #1
0
        //Manage journals when course is Ended
        // GET: /Journal/ManageJournal
        public ActionResult ManageJournal(int courseId, string userFirstNameFilter, string userLastNameFilter, int?page, string statusMessage)
        {
            logManager.AddEventLog("JournalController => ManageJournal ActionResult called(GET)", "ActionResult");
            ViewBag.StatusMessage   = statusMessage;
            ViewBag.FirstNameFilter = userFirstNameFilter;
            ViewBag.LastNameFilter  = userLastNameFilter;
            ViewBag.CourseId        = courseId;
            int pageSize     = 5;
            int pageNumber   = (page ?? 1);
            var journalsList = journalsManager.GetMarksForUsers(courseId);
            var course       = coursesManager.GetSpecificCourse(courseId);

            var courseLectorId = course.LectorId;
            var currentUserId  = User.Identity.GetUserId();

            if (courseLectorId == currentUserId && course.CourseStatus == Course.Status.Ended)
            {
                if (Request.HttpMethod == "POST")
                {
                    journalsList = usersManager.GetSortedUsersList(userFirstNameFilter, userLastNameFilter, null, journalsList);
                    List <JournalViewModel> journalsPost = JournalViewModel.GetJournalsList(journalsList, course);

                    return(View(journalsPost.ToPagedList(pageNumber, pageSize)));
                }
                journalsList = usersManager.GetSortedUsersList(userFirstNameFilter, userLastNameFilter, null, journalsList);
                List <JournalViewModel> journals = JournalViewModel.GetJournalsList(journalsList, course);

                return(View(journals.ToPagedList(pageNumber, pageSize)));
            }
            return(View("Error"));
        }
 //Delete specific course
 // GET: /Admin/ManageCourses/DeleteCourse
 public ActionResult DeleteCourse(int courseId)
 {
     logManager.AddEventLog("ManageCoursesController(Admin area) => DeleteCourse ActionResult called(GET)", "ActionResult");
     ViewBag.Course = coursesManager.GetSpecificCourse(courseId).CourseName;
     coursesManager.DeleteCourse(courseId);
     return(View());
 }
Example #3
0
        public static List <JournalViewModel> GetJournalsList(ICollection <Journal> journals, UsersManager usersManager, CoursesManager coursesManager)
        {
            LogManager logManager = new LogManager();

            logManager.AddEventLog("JournalViewModel => GetJournalsList 2nd method called", "Method");

            List <JournalViewModel> result = new List <JournalViewModel>();

            foreach (var item in journals)
            {
                var course     = coursesManager.GetSpecificCourse(item.CourseId);
                var lectorData = usersManager.GetSpecificUser(course.LectorId);
                var lector     = "None";
                if (lectorData != null)
                {
                    lector = string.Concat(lectorData.FirstName, " ", lectorData.LastName);
                }
                result.Add(new JournalViewModel(
                               item.Id,
                               item.Users.First().FirstName,
                               item.Users.First().LastName,
                               item.Mark,
                               course.CourseName,
                               course.Theme,
                               course.Id,
                               lector,
                               course.CourseStatus.ToString()
                               ));
            }
            return(result);
        }
Example #4
0
        //Display course information
        // GET: /Courses/CourseInfo
        public ActionResult CourseInfo(int courseId)
        {
            logManager.AddEventLog("CoursesController => CourseInfo ActionResult called(GET)", "ActionResult");
            var course = coursesManager.GetSpecificCourse(courseId);

            ViewBag.Lector = coursesManager.GetLectorInfo(course);
            string currentUserId = User.Identity.GetUserId();

            ViewBag.UserIsSignedToCourse = coursesManager.UserIsSignedToCourse(courseId, currentUserId);
            ViewBag.UserIsLector         = false;
            ViewBag.CourseStatusEnded    = false;

            if (course.CourseStatus == Course.Status.Ended)
            {
                ViewBag.CourseStatusEnded = true;
            }

            if (course.LectorId == currentUserId)
            {
                ViewBag.UserIsLectorOfThisCourse = true;
            }
            else
            {
                ViewBag.UserIsLectorOfThisCourse = false;
            }

            return(View(course));
        }
Example #5
0
        // GET: Lector
        public ActionResult LectorInfo(int courseId)
        {
            logManager.AddEventLog("LectorController => LectorInfo ActionResult called(GET)", "ActionResult");
            if (courseId == null)
            {
                return(View("Error"));
            }
            var lectorId = coursesManager.GetSpecificCourse(courseId).LectorId;
            var lector   = usersManager.GetSpecificUser(lectorId);

            ViewBag.CourseId = courseId;

            return(View(lector));
        }