public ActionResult Index() { account user = accountHelp.getCurrentUser(Session["User"].ToString()); int userId = user.id; ViewBag.userName = user.name; ViewBag.imagePath = user.imagePath; List <courses> info; if (user.roleId > 1) { info = CourseService.GetCoursesOfTeacher(userId); } else { info = CourseService.GetCoursesOfUser(userId); } return(View(info)); }
public ActionResult Index() { //Aquiring the current user to display his name and profile picture in the top right corner account user = accountHelper.getCurrentUser(Session["User"].ToString()); int userId = user.id; ViewBag.userName = user.name; ViewBag.imagePath = user.imagePath; HomeViewModel startInfo; //Render different info depending on if the user is a student or not. if (user.roleId == 1) { startInfo = new HomeViewModel { assignments = AssServ.GetAssignmentsOfUserHome(userId), courses = CoursServ.GetCoursesOfUser(userId), gradingService = new Services.GradingService(), account = user }; } else { startInfo = new HomeViewModel { assignments = AssServ.GetAssignmentsOfTeacherHome(userId), courses = CoursServ.GetCoursesOfTeacher(userId), gradingService = new Services.GradingService(), account = user }; } //render the homepage return(View(startInfo)); }