public ActionResult Details(int id) { #region Past Code //Student student = unit.StudentManager.GetById(id); //return View(student); #endregion Student student = unit.StudentManager.GetById(id); List <Course> courses = unit.CourseManager.GetAllBind(); List <Instructor> instructors = unit.InstructorManager.GetAllBind(); var courseId = student.StudentCourses.Where(a => a.Fk_StudentId == id). Select(a => a.Fk_CourseId).ToList(); courses = ctx.Courses.Where(a => courseId.Contains(a.Id)).ToList(); StudentCourseVM studentCourseVM = new StudentCourseVM { Courses = new List <Course>(), StudentName = student.Name, StudentId = student.Id, BirthDate = student.BirthDate, StudentMail = student.Mail, StudentPhone = student.Phone }; TempData["studentId"] = id; studentCourseVM.Courses = courses; return(View(studentCourseVM)); }
public ActionResult Enroll(int id) { Student student = unit.StudentManager.GetById(id); List <Course> courses = unit.CourseManager.GetAllBind(); courses = courses.Where(c => c.IsDeleted == false).ToList(); List <Instructor> instructors = unit.InstructorManager.GetAllBind(); StudentCourseVM studentCourseVM = new StudentCourseVM { Courses = new List <Course>(), StudentName = student.Name, StudentId = student.Id, }; studentCourseVM.Courses = courses; return(View(studentCourseVM)); }
// Enrollments doesn't need an index Action because there is no need to have a full landing page of just course and student associations. // GET: Enrollments/Details/5 public async Task <IActionResult> CourseDetails(int id) { var enrollments = _courses.GetEnrollmentsByCourse(id); if (enrollments == null) { return(NotFound()); } StudentCourseVM ecvm = new StudentCourseVM(); ecvm.Course = await _courses.GetCourseById(id); ecvm.Enrollments = enrollments; return(View(ecvm)); }
StudentProfileVM GetStudentFullProfile(string userId) { //Student Info var studentInfo = _repoStud.GetAll().Include(u => u.User).SingleOrDefault(u => u.ApplicationUserId == userId); StudentProfileVM studentProfile = new StudentProfileVM() { ProfileId = studentInfo.Id, BirthDate = studentInfo.User.BirthDate, Email = studentInfo.User.Email, FirstVisit = studentInfo.FirstVisit, Info = studentInfo.Info, Username = studentInfo.User.Name, Gender = studentInfo.User.Gender, Image = studentInfo.Image, University = studentInfo.Universty, UniverstyYearFrom = studentInfo.UniverstyYearFrom, UniverstyYearTo = studentInfo.UniverstyYearTo, SchholYearFrom = studentInfo.SchholYearFrom, SchholYearTo = studentInfo.SchholYearTo, UserId = studentInfo.ApplicationUserId, School = studentInfo.School, Title = studentInfo.Title }; //Student Skills var allSkills = GetStudentSkills(userId); List <StudentSkillVM> skillsList = new List <StudentSkillVM>(); foreach (var skill in allSkills) { StudentSkillVM studentSkill = new StudentSkillVM() { Id = skill.Id, SkillName = skill.Skill.Name }; skillsList.Add(studentSkill); } studentProfile.Skills = skillsList; //End Student Skills //Student Exams var allExams = GetStudentExams(userId); List <StudentExamVM> examsList = new List <StudentExamVM>(); foreach (var exam in allExams) { StudentExamVM studentExam = new StudentExamVM() { ExamName = exam.Exam.Title, StudentDegree = exam.Degree }; examsList.Add(studentExam); } studentProfile.Exams = examsList; //End Student Exams //Student Courses var allCourses = GetStudentCourses(userId); List <StudentCourseVM> coursesList = new List <StudentCourseVM>(); foreach (var course in allCourses) { StudentCourseVM studentCourse = new StudentCourseVM() { CourseName = course.Course.Name, Info = course.Course.Info }; coursesList.Add(studentCourse); } studentProfile.Courses = coursesList; //End Student Courses //Student Firneds var allFriends = GetStudentFriends(userId); List <StudentFollowingVM> finedsList = new List <StudentFollowingVM>(); foreach (var frined in allFriends) { var friendData = GetStudent(frined.FriendTwoId); if (friendData != null) { StudentFollowingVM studentFriend = new StudentFollowingVM() { Id = frined.Id, Name = frined.FriendTwo.Name, FriendId = frined.FriendTwo.Id, Title = friendData.Title, FriendImage = friendData.Image, Gender = friendData.User.Gender }; finedsList.Add(studentFriend); } } studentProfile.Friends = finedsList; //End Student Firneds //Student Questions var allQuestions = GetStudentQuestions(userId); List <StudentQuestionVM> questionsList = new List <StudentQuestionVM>(); foreach (var question in allQuestions) { var studentData = GetStudent(question.UserId); if (studentData != null) { StudentQuestionVM studentQuestion = new StudentQuestionVM() { Id = question.Id, Dislikes = question.Dislikes, Likes = question.Likes, QuestionHead = question.QuestionHead, Username = question.User.Name, Image = studentData.Image, UserId = question.UserId }; List <QuestionAnswerVM> questionAnswersList = new List <QuestionAnswerVM>(); foreach (var answer in question.Answers) { QuestionAnswerVM Answer = new QuestionAnswerVM() { Answer = answer.QuestionAnswer, Id = answer.Id, UserId = answer.UserId, Username = answer.User.Name, //UserImage = answer.User.Student.Image }; questionAnswersList.Add(Answer); }//End Answers ForLoop studentQuestion.Answers = questionAnswersList; questionsList.Add(studentQuestion); } }//End Questions ForLoop studentProfile.Questions = questionsList; //End Student Questions return(studentProfile); }//End Get Profile