//Subjects Name Binding private void BindSubjectname() { List<Subject_Master> s = dbcontext.Subject_Master.Where(x => x.SubjectID != 0).ToList(); Subject_Master sub = new Subject_Master { Name = "Please select Course", SubjectID = 0 }; s.Insert(0, sub); SelectList selectsubject = new SelectList(s, "SubjectID", "Name", 0); ViewBag.selectedsubject = selectsubject; }
//Binding subjects by user course wise private void BindSubjectByUser() { var getCourseID = (from profile in dbcontext.StudentProfiles where profile.EmailID == User.Identity.Name select profile.Course).FirstOrDefault(); List <Subject_Master> s = dbcontext.Subject_Master.Where(x => x.Course == getCourseID).ToList(); Subject_Master sub = new Subject_Master { Name = "----Please select Course----", SubjectID = 0 }; s.Insert(0, sub); SelectList selectsubject = new SelectList(s, "SubjectID", "Name", 0); ViewBag.selectedsubject = selectsubject; }
public ActionResult Index() { //JobsNotification Begin var JobsNotification = dbcontext.Job_Master.Where(i => i.JobID != 0).ToList(); ViewBag.JobsN = JobsNotification; //JobsNotification End //StudyMaterials Begin var StudyMaterialsNotification = dbcontext.StudyMaterials.Where(i => i.SM_Name != null).Take(3).ToList(); ViewBag.studymN = StudyMaterialsNotification; //StudyMaterials End var StudentName = (from a in dbcontext.StudentProfiles.Where(x => x.EmailID == User.Identity.Name) select a.Name).FirstOrDefault(); ViewBag.name = StudentName; //Additional Question Request Begin var AddQueReq = (from Qreq in dbcontext.Stu_Additionalquestionrequest join user in dbcontext.StudentProfiles on Qreq.ProfileId equals user.Student_ID join course in dbcontext.Course_master on Qreq.Course equals course.Course_ID //where user.EmailID == User.Identity.Name select new QuestionRequestModel { StudentName = user.Name, Course = course.Name, Update = (bool)Qreq.Updated == true ? "Updated" : "Pending", }).Take(2).ToList(); ViewBag.QueReq = AddQueReq; //Additional Question Request End var Student = new GetUserByUserName(User.Identity.Name); var CourseID = Student.CourseID; var SemID = Student.SemID; var Student_ID = Student.Student_ID; var UnitID = Student.UnitID; var SubjectID = Student.SubjectID; List <Subject_Master> s = dbcontext.Subject_Master.Where(x => x.Course == CourseID && x.Semester == SemID).ToList(); Subject_Master sub = new Subject_Master { Name = "----please select Course----", SubjectID = 0 }; s.Insert(0, sub); SelectList selectsubject = new SelectList(s, "SubjectID", "Name", 0); ViewBag.selectedsubject = selectsubject; List <UnitMaster> u = dbcontext.UnitMasters.ToList(); UnitMaster unit = new UnitMaster { UnitName = "----Please select unit----", Uid = 0 }; u.Insert(0, unit); SelectList selectunit = new SelectList(u, "Uid", "UnitName", 0); ViewBag.selectedunit = selectunit; return(View()); }