public ActionResult ShowTeacherSubjects() { int userId = LoginFilter.GetUserId(); SubjectRepository repository = new SubjectRepository(); List <Subject> subjects = repository.GetAll(); List <Subject> teacherSubjects = new List <Subject>(); foreach (var subject in subjects) { if (subject.TeacherId == userId) { teacherSubjects.Add(subject); } else { ViewBag.Message = "This user has no subjects yet!"; } } SubjectListViewModel model = new SubjectListViewModel(); model.Subjects = teacherSubjects; return(View(model)); }
public ActionResult EditCourseSubject(AdminControllerCourseSubjectVM courseSubjectModel) { CourseSubject courseSubject = new CourseSubject(); CourseSubjectRepository courseSubjectRepository = new CourseSubjectRepository(); TryUpdateModel(courseSubjectModel); if (ModelState.IsValid && courseSubjectModel.CourseSubjectID > 0) { courseSubject.CourseID = courseSubjectModel.courseID; courseSubject.SubjectID = courseSubjectModel.subjectID; courseSubjectRepository.Save(courseSubject); return(RedirectToAction("ShowSubjects", "Admin", new { @id = courseSubjectModel.courseID })); } if (courseSubjectModel.ListItems == null) { List <SelectListItem> List = new List <SelectListItem>(); SubjectRepository subjectRepository = new SubjectRepository(); courseSubjectModel.subjectList = subjectRepository.GetAll(); foreach (var item in courseSubjectModel.subjectList) { List.Add(new SelectListItem() { Text = item.Name, Value = item.Id.ToString() }); } courseSubjectModel.ListItems = List; } return(View(courseSubjectModel)); }
public void SubjectRepositoryTest1() { var repo = new SubjectRepository(); var subject = repo.GetAll().FirstOrDefault(); Assert.IsInstanceOfType(subject, typeof(Subject)); }
public JsonResult GetAll() { using (var subjectRepository = new SubjectRepository()) { return(Json(subjectRepository.GetAll(), JsonRequestBehavior.AllowGet)); } }
public ActionResult EditSubjects(int id, AdminControllerSubjectVM subjectModel) { TryUpdateModel(subjectModel); if (ModelState.IsValid) { Subject subject = null; SubjectRepository subjectRepository = new SubjectRepository(); if (id > 0) { subject = subjectRepository.GetById(id); subject.Name = subjectModel.Name; subjectRepository.Save(subject); return(RedirectToAction("ManageSubjects")); } else { subject = subjectRepository.GetAll(filter: s => s.Name == subjectModel.Name).FirstOrDefault(); if (subject == null) { subject = new Subject(); subject.Name = subjectModel.Name; subjectRepository.Save(subject); return(RedirectToAction("ManageSubjects")); } else { throw new ArgumentException("Invalid subject name"); } } } return(View(subjectModel)); }
public ActionResult Index() { SubjectRepository SR = SubjectRepository.Instance; IEnumerable <Models.Subject> Subjects = SR.GetAll(); return(View("/Views/Pages/Home/index.cshtml", Subjects)); }
public ActionResult List() { // Get all the subjects and map them to view models. var subjects = _subjectRepository.GetAll().Where(s => s.Class.CounselerId == Counseler.Id); var model = Mapper.Map <List <SubjectModel> >(subjects); return(View(model)); }
//public ActionResult DeleteTitle(int id) //{ // Title title = new Title(); // TitleRepository titleRepository = new TitleRepository(); // TeacherRepository teacherRepository = new TeacherRepository(); // title = titleRepository.GetById(id); // if (teacherRepository.GetAll(filter: t => t.TitleID == title.Id) == null) // { // titleRepository.Delete(title); // } // else // { // } // return RedirectToAction("ManageTitles"); //} #endregion #region ManageSubjects public ActionResult ManageSubjects() { SubjectRepository subjectRepository = new SubjectRepository(); AdminControllerSubjectVM subjectModel = new AdminControllerSubjectVM(); subjectModel.subjectList = subjectRepository.GetAll(); return(View(subjectModel)); }
public ActionResult ManageCourseSubject() { AdminControllerCourseSubjectVM courseSubModel = new AdminControllerCourseSubjectVM(); SubjectRepository subjectRepository = new SubjectRepository(); CourseRepository courseRepository = new CourseRepository(); courseSubModel.courseList = courseRepository.GetAll(); courseSubModel.subjectList = subjectRepository.GetAll(); return(View(courseSubModel)); }
public IHttpActionResult GetAllSubjects() { var subjects = subjectRepo.GetAll(); if (!subjects.Any()) { return(Content(HttpStatusCode.NotFound, "List is empty")); } return(Ok(subjects)); }
public ActionResult Index() { SubjectRepository repository = new SubjectRepository(); List <Subject> subjects = repository.GetAll(); SubjectListViewModel model = new SubjectListViewModel(); model.Subjects = subjects; return(View(model)); }
public JsonResult Index() { var allSubjects = new List <SubjectViewModel>(); foreach (var subject in _subjectRepository.GetAll()) { var subjectToView = Mapper.Map <SubjectViewModel>(subject); subjectToView.ClassNameToDisplay = _classesRepository.GetClassNameAndDivisionBy(subjectToView.ClassId); allSubjects.Add(subjectToView); } return(Json(new { result = allSubjects }, JsonRequestBehavior.AllowGet)); }
public ActionResult EditCourseSubject(int courseID) { AdminControllerCourseSubjectVM courseSubjectModel = new AdminControllerCourseSubjectVM(); SubjectRepository subjectRepository = new SubjectRepository(); CourseSubjectRepository courseSubjectRepo = new CourseSubjectRepository(); List <Subject> subjectList = courseSubjectRepo.GetAll(filter: cs => cs.Course.Id == courseID).Select(s => s.Subject).ToList(); courseSubjectModel.subjectList = subjectRepository.GetAll();//Except method is overriden List <SelectListItem> List = new List <SelectListItem>(); foreach (var item in courseSubjectModel.subjectList) { List.Add(new SelectListItem() { Text = item.Name, Value = item.Id.ToString() }); } courseSubjectModel.ListItems = List; courseSubjectModel.subjectList = subjectRepository.GetAll(); courseSubjectModel.courseID = courseID; courseSubjectModel.CourseSubjectID = courseID; return(View(courseSubjectModel)); }
public void Get_all_subjects_test() { var repo = new SubjectRepository(context); var model = new SubjectEntity("AM", "Analiza matematyczna"); var model2 = new SubjectEntity("MD", "Matematyka dyskretna"); repo.AddNew(model); repo.AddNew(model2); var result = repo.GetAll(); Assert.IsNotNull(result); Assert.AreEqual(result.Count, 2); Assert.AreEqual(model.Id, result[0].Id); Assert.AreEqual(model2.Id, result[1].Id); }
public ActionResult Dashboard() { // Create the dashboard for a student with their subjects, presences and appointments. var student = Student; var model = new StudentDashboardModel { Subjects = _subjectRepository.GetAll() .Where(s => s.StartDate.Date == DateTime.Now.Date) .ToList(), Presences = _presenceRepository.GetByStudent(student.Id), Appointments = _appointmentRepository.GetAppointmentsByStudent(student.Id, GetFirstSaturday(), DateTime.Now) }; return(View(model)); }
public ActionResult EditSubject(int? id) { SubjectEditSubjectVM model = new SubjectEditSubjectVM(); model.Action = "Create"; if (id != null) { SubjectRepository subjectRepo = new SubjectRepository(); Subject subject = subjectRepo.GetAll(filter: s => s.ID == id.Value).FirstOrDefault(); model.Action = "Edit"; model.SubjectID = subject.ID; model.SubjectName = subject.Name; } return View(model); }
public ActionResult Home() { AdminControllerAdminVM model = new AdminControllerAdminVM(); StudentRepository studentRepository = new StudentRepository(); TeacherRepository teacherRepository = new TeacherRepository(); CourseRepository courseRepository = new CourseRepository(); SubjectRepository subjectRepository = new SubjectRepository(); TitleRepository titleRepository = new TitleRepository(); model.ActiveStudentCount = studentRepository.GetAll(filter: s => s.IsActive == true).Count; model.InActiveStudentCount = studentRepository.GetAll(filter: s => s.IsActive == false).Count; model.ActiveTeacherCount = teacherRepository.GetAll(filter: t => t.IsActive == true).Count; model.InActiveTeacherCount = teacherRepository.GetAll(filter: t => t.IsActive == false).Count; model.CourseCount = courseRepository.GetAll().Count; model.SubjectCount = subjectRepository.GetAll().Count; model.TitleCount = titleRepository.GetAll().Count(); Administrator admin = new Administrator(); AdministratorRepository adminRepository = new AdministratorRepository(); admin = adminRepository.GetById(AuthenticationManager.LoggedUser.Id); model.FirstName = admin.FirstName; model.LastName = admin.LastName; return(View(model)); }
/// <summary> /// Groups this instance. /// To fire this action, click on group icon near column that want to be grouped. /// </summary> /// <returns>Data that already grouped.</returns> public ActionResult Group(string groupby) { List <Student> students = studentRepo.GetAll(); List <Subject> subject = subjectRepo.GetAll(); List <SubjectAssignment> subjectAssignments = subjectAssignmentRepo.GetAll(); var data = (List <SubjectAssignment>)null; //// Join and Grouping switch (groupby) { case "stdname": data = //(List<SubjectAssignment>) (from sa in subjectAssignments join std in students on sa.StudentID equals std.StudentID group sa by std.StudentName into sagroup select sagroup).SelectMany(d => d).ToList(); break; case "sbname": data = //(List<SubjectAssignment>) (from sa in subjectAssignments join sb in subject on sa.SubjectId equals sb.SubjectId group sa by sb.SubjectName into sagroup select sagroup).SelectMany(d => d).ToList(); break; default: data = //(List<SubjectAssignment>) (from sa in subjectAssignments select sa).ToList(); break; } return(View("Index", data)); }
public ActionResult Subject() { return(View(SubjectRepo.GetAll())); }
public IEnumerable <Subject> GetAll() { return(repository.GetAll()); }
public IHttpActionResult Get() { return(Ok(subRepo.GetAll())); }
/// <summary> /// List all subjects /// </summary> /// <returns>List of subjects</returns> public ActionResult ListSubjects() { SubjectListSubjectsVM model = new SubjectListSubjectsVM(); UserRepository<Student> stuRepo = new UserRepository<Student>(); SubjectRepository subjRepo = new SubjectRepository(); List<Student> student = stuRepo.GetAll(); var subjects = subjRepo.GetAll(); var subjectList = new Dictionary<Subject, int>(); foreach (var subject in subjects) { int count = 0; if (student.Any(s => s.Course.CourseSubject.Any(x => x.SubjectID == subject.ID))) { count = student.Count(x => x.Course.CourseSubject.Any(c => c.SubjectID == subject.ID)); } subjectList.Add(subject, count); } model.SubjectList = subjectList; return View(model); }
public ActionResult EditCourseSubject(AdminControllerCourseSubjectVM courseSubjectModel) { CourseSubject courseSubject = new CourseSubject(); CourseSubjectRepository courseSubjectRepository = new CourseSubjectRepository(); TryUpdateModel(courseSubjectModel); if (ModelState.IsValid && courseSubjectModel.CourseSubjectID > 0) { courseSubject.CourseID = courseSubjectModel.courseID; courseSubject.SubjectID = courseSubjectModel.subjectID; courseSubjectRepository.Save(courseSubject); return RedirectToAction("ShowSubjects", "Admin", new { @id = courseSubjectModel.courseID }); } if (courseSubjectModel.ListItems == null) { List<SelectListItem> List = new List<SelectListItem>(); SubjectRepository subjectRepository = new SubjectRepository(); courseSubjectModel.subjectList = subjectRepository.GetAll(); foreach (var item in courseSubjectModel.subjectList) { List.Add(new SelectListItem() { Text = item.Name, Value = item.Id.ToString() }); } courseSubjectModel.ListItems = List; } return View(courseSubjectModel); }
public ActionResult EditCourseSubject(int courseID) { AdminControllerCourseSubjectVM courseSubjectModel = new AdminControllerCourseSubjectVM(); SubjectRepository subjectRepository = new SubjectRepository(); CourseSubjectRepository courseSubjectRepo = new CourseSubjectRepository(); List<Subject> subjectList = courseSubjectRepo.GetAll(filter: cs => cs.Course.Id == courseID).Select(s => s.Subject).ToList(); courseSubjectModel.subjectList = subjectRepository.GetAll();//Except method is overriden List<SelectListItem> List = new List<SelectListItem>(); foreach (var item in courseSubjectModel.subjectList) { List.Add(new SelectListItem() { Text = item.Name, Value = item.Id.ToString() }); } courseSubjectModel.ListItems = List; courseSubjectModel.subjectList = subjectRepository.GetAll(); courseSubjectModel.courseID = courseID; courseSubjectModel.CourseSubjectID = courseID; return View(courseSubjectModel); }
public JsonResult CheckForExistingName(string name, string type, int id) { bool exist = false; switch (type) { case "Admin": Administrator admin = new Administrator(); AdministratorRepository adminRepository = new AdministratorRepository(); admin = adminRepository.GetAll(filter: a => a.UserName == name && a.Id != id).FirstOrDefault(); if (admin != null) { exist = true; }; break; case "Student": Student student = new Student(); StudentRepository studentRepository = new StudentRepository(); student = studentRepository.GetAll(filter: s => s.UserName == name && s.Id != id).FirstOrDefault(); if (student != null) { exist = true; }; break; case "Teacher": Teacher teacher = new Teacher(); TeacherRepository teacherRepository = new TeacherRepository(); teacher = teacherRepository.GetAll(filter: t => t.UserName == name && t.Id != id).FirstOrDefault(); if (teacher != null) { exist = true; }; break; case "Course": Course course = new Course(); CourseRepository courseRepository = new CourseRepository(); course = courseRepository.GetAll(filter: c => c.Name == name).FirstOrDefault(); if (course != null) { exist = true; }; break; case "Title": Title title = new Title(); TitleRepository titleRepository = new TitleRepository(); title = titleRepository.GetAll(filter: t => t.Name == name).FirstOrDefault(); if (title != null) { exist = true; }; break; case "Subject": Subject subject = new Subject(); SubjectRepository subjectRepository = new SubjectRepository(); subject = subjectRepository.GetAll(filter: s => s.Name == name).FirstOrDefault(); if (subject != null) { exist = true; }; break; } return Json(exist, JsonRequestBehavior.AllowGet); }
public ActionResult Index() { TeacherIndexVM model = new TeacherIndexVM(); CourseRepository courseRepo = new CourseRepository(); SubjectRepository subjRepo = new SubjectRepository(); CourseSubjectRepository csRepo = new CourseSubjectRepository(); model.Subjects = subjRepo.GetAll(filter: s => s.CourseSubject.Any(c => c.Teachers.Any(t => t.ID == UniversitySystem.Models.AuthenticationManager.LoggedUser.ID))); model.Courses = courseRepo.GetAll(filter: c => c.CourseSubject.Any(s => s.Teachers.Any(t => t.ID == UniversitySystem.Models.AuthenticationManager.LoggedUser.ID))); return View(model); }
public ActionResult Home() { AdminControllerAdminVM model = new AdminControllerAdminVM(); StudentRepository studentRepository = new StudentRepository(); TeacherRepository teacherRepository = new TeacherRepository(); CourseRepository courseRepository = new CourseRepository(); SubjectRepository subjectRepository = new SubjectRepository(); TitleRepository titleRepository = new TitleRepository(); model.ActiveStudentCount = studentRepository.GetAll(filter: s => s.IsActive == true).Count; model.InActiveStudentCount = studentRepository.GetAll(filter: s => s.IsActive == false).Count; model.ActiveTeacherCount = teacherRepository.GetAll(filter: t => t.IsActive == true).Count; model.InActiveTeacherCount = teacherRepository.GetAll(filter: t => t.IsActive == false).Count; model.CourseCount = courseRepository.GetAll().Count; model.SubjectCount = subjectRepository.GetAll().Count; model.TitleCount = titleRepository.GetAll().Count(); Administrator admin = new Administrator(); AdministratorRepository adminRepository = new AdministratorRepository(); admin = adminRepository.GetById(AuthenticationManager.LoggedUser.Id); model.FirstName = admin.FirstName; model.LastName = admin.LastName; return View(model); }
public JsonResult CheckForExistingName(string name, string type, int id) { bool exist = false; switch (type) { case "Admin": Administrator admin = new Administrator(); AdministratorRepository adminRepository = new AdministratorRepository(); admin = adminRepository.GetAll(filter: a => a.UserName == name && a.Id != id).FirstOrDefault(); if (admin != null) { exist = true; } ; break; case "Student": Student student = new Student(); StudentRepository studentRepository = new StudentRepository(); student = studentRepository.GetAll(filter: s => s.UserName == name && s.Id != id).FirstOrDefault(); if (student != null) { exist = true; } ; break; case "Teacher": Teacher teacher = new Teacher(); TeacherRepository teacherRepository = new TeacherRepository(); teacher = teacherRepository.GetAll(filter: t => t.UserName == name && t.Id != id).FirstOrDefault(); if (teacher != null) { exist = true; } ; break; case "Course": Course course = new Course(); CourseRepository courseRepository = new CourseRepository(); course = courseRepository.GetAll(filter: c => c.Name == name).FirstOrDefault(); if (course != null) { exist = true; } ; break; case "Title": Title title = new Title(); TitleRepository titleRepository = new TitleRepository(); title = titleRepository.GetAll(filter: t => t.Name == name).FirstOrDefault(); if (title != null) { exist = true; } ; break; case "Subject": Subject subject = new Subject(); SubjectRepository subjectRepository = new SubjectRepository(); subject = subjectRepository.GetAll(filter: s => s.Name == name).FirstOrDefault(); if (subject != null) { exist = true; } ; break; } return(Json(exist, JsonRequestBehavior.AllowGet)); }
public IQueryable <Subject> GetAllSubjects() { return(subjectRepository.GetAll()); }
public ActionResult ManageCourseSubject() { AdminControllerCourseSubjectVM courseSubModel = new AdminControllerCourseSubjectVM(); SubjectRepository subjectRepository = new SubjectRepository(); CourseRepository courseRepository = new CourseRepository(); courseSubModel.courseList = courseRepository.GetAll(); courseSubModel.subjectList = subjectRepository.GetAll(); return View(courseSubModel); }
public ActionResult EditSubjects(int id, AdminControllerSubjectVM subjectModel) { TryUpdateModel(subjectModel); if (ModelState.IsValid) { Subject subject = null; SubjectRepository subjectRepository = new SubjectRepository(); if (id > 0) { subject = subjectRepository.GetById(id); subject.Name = subjectModel.Name; subjectRepository.Save(subject); return RedirectToAction("ManageSubjects"); } else { subject = subjectRepository.GetAll(filter: s => s.Name == subjectModel.Name).FirstOrDefault(); if (subject == null) { subject = new Subject(); subject.Name = subjectModel.Name; subjectRepository.Save(subject); return RedirectToAction("ManageSubjects"); } else { throw new ArgumentException("Invalid subject name"); } } } return View(subjectModel); }
public ActionResult ManageSubjects() { SubjectRepository subjectRepository = new SubjectRepository(); AdminControllerSubjectVM subjectModel = new AdminControllerSubjectVM(); subjectModel.subjectList = subjectRepository.GetAll(); return View(subjectModel); }