示例#1
0
        public ActionResult Index()
        {
            ApplicationUser currentUser      = db.Users.Find(User.Identity.GetUserId());
            var             popularTutorials = db.Tutorials.OrderByDescending(x => x.Votes).Take(5).ToList();

            if (currentUser.LearningPathModel == null)
            {
                currentUser.LearningPathModel = new LearningPathModel();
            }
            if (isStudent())
            {
                StudentViewModel studentVM = new StudentViewModel
                {
                    CurrentUser      = currentUser,
                    PopularTutorials = popularTutorials
                };
                return(View("Student", studentVM));
            }
            else
            {
                var educatorsTutorials = db.Tutorials.Where(x => x.EducatorId == currentUser.Id).ToList();
                educatorsTutorials.ForEach(x => currentUser.Points += x.Votes);
                var educatorsQuizzes = db.Quiz.Where(x => x.EducatorId == currentUser.Id).ToList();
                List <CollaborativeTutorial> acttt        = GetAddedCollaboratorsList(educatorsTutorials);
                EducatorViewModel            eduViewModel = new EducatorViewModel()
                {
                    EducatorTutorials      = educatorsTutorials,
                    CollaborativeTutorials = GetCollabTutorials(),
                    EducatorQuizzes        = educatorsQuizzes,
                    Points           = currentUser.Points,
                    PopularTutorials = popularTutorials,
                    AddedCollaboratorsToTheseTutorials = acttt
                };
                return(View("Educator", eduViewModel));
            }
        }
示例#2
0
 public ActionResult Index()
 {
     ApplicationUser currentUser = db.Users.Find(User.Identity.GetUserId());
     var popularTutorials = db.Tutorials.OrderByDescending(x => x.Votes).Take(5).ToList();
     if (currentUser.LearningPathModel == null)
     {
         currentUser.LearningPathModel = new LearningPathModel();
     }
     if (isStudent())
     {
         StudentViewModel studentVM = new StudentViewModel
         {
             CurrentUser = currentUser,
             PopularTutorials = popularTutorials
         };
         return View("Student", studentVM);
     }
     else
     {
         var educatorsTutorials = db.Tutorials.Where(x => x.EducatorId == currentUser.Id).ToList();
         educatorsTutorials.ForEach(x => currentUser.Points += x.Votes);
         var educatorsQuizzes = db.Quiz.Where(x => x.EducatorId == currentUser.Id).ToList();
         List<CollaborativeTutorial> acttt = GetAddedCollaboratorsList(educatorsTutorials);
         EducatorViewModel eduViewModel = new EducatorViewModel()
         {
             EducatorTutorials = educatorsTutorials,
             CollaborativeTutorials = GetCollabTutorials(),
             EducatorQuizzes = educatorsQuizzes,
             Points = currentUser.Points,
             PopularTutorials = popularTutorials,
             AddedCollaboratorsToTheseTutorials = acttt
         };
         return View("Educator", eduViewModel);
     }
 }