public ActionResult Inscripcion(int Id) { oUsuario = (Student)HttpContext.Session["Usuario"]; InscripcionViewModel model = new InscripcionViewModel(); using (CollegeEntities bd = new CollegeEntities()) { var materia = bd.Course.Find(Id); Course curso = materia; var CountInscriptos = (from m in bd.Course_Student where m.Id_Course == curso.Id_Course select m.Id_Course).ToList(); int Inscriptos = CountInscriptos.Count(); if (Inscriptos < materia.Maximun_Number_Of_Students) { var OInscripcion = new Course_Student(); OInscripcion.Id_Course = materia.Id_Course; OInscripcion.Id_Student = oUsuario.Id_Student; bd.Course_Student.Add(OInscripcion); bd.SaveChanges(); return(RedirectToAction("Index", new { message = "se inscribio correctamente" })); } else { return(RedirectToAction("Index", new { message = "cupo completo" })); } } }
public ActionResult ConfirmEnrollment(string idStudent, int idCourse) { Course_Student enrollment = new Course_Student(); enrollment.curse_id = idCourse; enrollment.student_identification = idStudent; db.Course_Student.Add(enrollment); Student student = db.Student.Find(idStudent); student.Course_Student.Add(enrollment); Course course = db.Course.Find(idCourse); db.SaveChanges(); ViewBag.studentId = student.identification; ViewBag.studentName = student.name; ViewBag.studentLastName = student.last_name; ViewBag.curseName = course.name; return(View()); }
public ActionResult DeleteWarning() { Responsable responsable = db.Responsable.Include(a => a.Student).ToList().Find(c => c.identification == idResponsable); List <Student> studentList = responsable.Student.ToList(); for (int i = 0; i < studentList.Count; i++) { string idStudent = studentList[i].identification; Student student = db.Student.Find(idStudent); Course_Student curse_Student = db.Course_Student.Include(a => a.Student).ToList().Find(c => c.student_identification == idStudent); if (curse_Student != null) { db.Course_Student.Remove(curse_Student); } db.Student.Remove(student); db.SaveChanges(); } responsable.Student.Clear(); db.Responsable.Remove(responsable); try { db.SaveChanges(); } catch (Exception e) { } return(RedirectToAction("Index", new { message = "El responsable y los estudiantes se eliminaron exitosamente" })); }
public ActionResult DeleteEnrollment(string idStudent, int idCourse) { Student student = db.Student.Find(idStudent); Course course = db.Course.Find(idCourse); List <Course_Student> enrollments = course.Course_Student.ToList(); ViewBag.studentId = student.identification; ViewBag.studentName = student.name; ViewBag.studentLastName = student.last_name; ViewBag.curseName = course.name; for (int i = 0; i < enrollments.Count(); i++) { Course_Student enrollment = enrollments[i]; if (enrollment.curse_id == idCourse && enrollment.student_identification.Equals(idStudent)) { db.Course_Student.Remove(enrollment); } } db.SaveChanges(); return(View()); }
/// <summary> /// A function that removes a user from a course /// </summary> public ActionResult RemoveFromCourse(string ID, int courseID, string role) { #region Security if (EnforceSecurity(SecurityState.ADMIN) != null) { return(EnforceSecurity(SecurityState.ADMIN)); } #endregion if (role == "Teacher") { Course_Teacher teacherToDelete = (from x in db.CoursesTeachers where x.TeacherID == ID && x.CourseID == courseID select x).SingleOrDefault(); db.CoursesTeachers.Remove(teacherToDelete); db.SaveChanges(); } else if (role == "Student") { Course_Student studentToDelete = (from x in db.CoursesStudents where x.UserID == ID && x.CourseID == courseID select x).SingleOrDefault(); db.CoursesStudents.Remove(studentToDelete); db.SaveChanges(); } return(RedirectToAction("CourseConnections", new { courseID = courseID })); }
public ActionResult DeleteConfirmed(int id) { Course_Student course_Student = db.Course_Student.Find(id); db.Course_Student.Remove(course_Student); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "ID,StudentID,CourseID")] Course_Student course_Student) { if (ModelState.IsValid) { db.Entry(course_Student).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.CourseID = new SelectList(db.Courses, "ID", "Title", course_Student.CourseID); ViewBag.StudentID = new SelectList(db.Students, "ID", "Name", course_Student.StudentID); return(View(course_Student)); }
/// <summary> /// A function that connects a student to a course in the database /// </summary> public void ConnectStudents(string userID, int courseID) { Course_Student newStudent = new Course_Student { UserID = userID, CourseID = courseID }; db.CoursesStudents.Add(newStudent); db.SaveChanges(); return; }
public ActionResult Create([Bind(Include = "ID,CourseID,StudentID")] Course_Student course_Student) { if (ModelState.IsValid) { db.Course_Student.Add(course_Student); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.CourseID = new SelectList(db.Courses, "ID", "CourseTitle", course_Student.CourseID); ViewBag.StudentID = new SelectList(db.Students, "ID", "Name", course_Student.StudentID); return(View(course_Student)); }
// GET: Courses_Students/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Course_Student course_Student = db.Course_Student.Find(id); if (course_Student == null) { return(HttpNotFound()); } return(View(course_Student)); }
// GET: Courses_Students/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Course_Student course_Student = db.Course_Student.Find(id); if (course_Student == null) { return(HttpNotFound()); } ViewBag.CourseID = new SelectList(db.Courses, "ID", "Title", course_Student.CourseID); ViewBag.StudentID = new SelectList(db.Students, "ID", "Name", course_Student.StudentID); return(View(course_Student)); }
public ActionResult DeleteConfirmed(string id) { Student student = db.Student.Find(id); Course_Student curse_Student = db.Course_Student.Include(a => a.Student).ToList().Find(c => c.student_identification == id); if (curse_Student != null) { db.Course_Student.Remove(curse_Student); } db.Student.Remove(student); db.SaveChanges(); return(RedirectToAction("Index", new { message = "El estudiante se eliminó exitosamente" })); }
public ActionResult StudentDetails() { Course programming = new Course(); programming.CourseId = 01; programming.CourseName = "Programming 101"; programming.TotalCredits = 70; Students alex = new Students(); alex.StudentId = 1; alex.Name = "Alex"; alex.Surname = "Xela"; alex.Gender = "Male"; alex.Age = 21; alex.Country = "Sweden"; Students xobile = new Students(); xobile.StudentId = 2; xobile.Name = "Xobile"; xobile.Surname = "Elibox"; xobile.Gender = "Male"; xobile.Age = 21; xobile.Country = "England"; Students samantha = new Students(); samantha.StudentId = 3; samantha.Name = "Samantha"; samantha.Surname = "Athnamas"; samantha.Gender = "Female"; samantha.Age = 21; samantha.Country = "Russia"; List<Students> studentInfo = new List<Students>(); studentInfo.Add(alex); studentInfo.Add(xobile); studentInfo.Add(samantha); Course_Student obj = new Course_Student(); obj.course = programming; obj.students = studentInfo; return View(obj); }
public void Initialize() { MockDataContext mock = new MockDataContext(); #region Users ApplicationUser user1 = new ApplicationUser { Id = "1", Ssn = "1211", Email = "*****@*****.**", UserName = "******" }; ApplicationUser user2 = new ApplicationUser { Id = "2", Ssn = "2122", Email = "*****@*****.**", UserName = "******" }; ApplicationUser user3 = new ApplicationUser { Id = "3", Ssn = "3102", Email = "*****@*****.**", UserName = "******" }; ApplicationUser user4 = new ApplicationUser { Id = "4", Ssn = "3789", Email = "*****@*****.**", UserName = "******" }; mock.Users.Add(user1); mock.Users.Add(user2); mock.Users.Add(user3); mock.Users.Add(user4); #endregion #region Assignments Assignment assignment1 = new Assignment { ID = 1, Title = "HelloWorld", Weight = 30, CourseID = 1, TestCases = "swag", Description = "Forrita Hello World!", ProgrammingLanguageID = 1, DateCreated = new DateTime(2016, 6, 20), DueDate = new DateTime(2016, 6, 30) }; mock.Assignments.Add(assignment1); #endregion #region Milestones Milestone milestone1 = new Milestone { ID = 1, AssignmentID = 1, Weight = 20, Title = "mila", Description = "mæla milu", Input = "km", Output = "milan", Code = "1km", TestCases = "profa km", ProgrammingLanguageID = 1, DateCreated = new DateTime(2016, 4, 20), DueDate = new DateTime(2016, 4, 30) }; Milestone milestone2 = new Milestone { ID = 2, AssignmentID = 1, Weight = 25, Title = "samlagning", Description = "leggja saman tölur", Input = "2,8", Output = "10", Code = "cout << 2 + 8;", TestCases = "profa tolur", ProgrammingLanguageID = 2, DateCreated = new DateTime(2016, 5, 20), DueDate = new DateTime(2016, 5, 30) }; Milestone milestone3 = new Milestone { ID = 3, AssignmentID = 2, Weight = 25, Title = "samlagning", Description = "leggja saman tölur", Input = "2,4", Output = "6", Code = "cout << 2 + 4;", TestCases = "profa tolur", ProgrammingLanguageID = 2, DateCreated = new DateTime(2016, 3, 20), DueDate = new DateTime(2016, 3, 30) }; mock.Milestones.Add(milestone1); mock.Milestones.Add(milestone2); mock.Milestones.Add(milestone3); #endregion #region CourseTeachers Course_Teacher courseTeacher1 = new Course_Teacher { ID = 1, CourseID = 1, TeacherID = "1" }; Course_Teacher courseTeacher2 = new Course_Teacher { ID = 2, CourseID = 2, TeacherID = "2" }; Course_Teacher courseTeacher3 = new Course_Teacher { ID = 3, CourseID = 1, TeacherID = "3" }; Course_Teacher courseTeacher4 = new Course_Teacher { ID = 4, CourseID = 1, TeacherID = "4" }; mock.CoursesTeachers.Add(courseTeacher1); mock.CoursesTeachers.Add(courseTeacher2); mock.CoursesTeachers.Add(courseTeacher3); mock.CoursesTeachers.Add(courseTeacher4); #endregion #region CourseStudents Course_Student courseStudent1 = new Course_Student { ID = 1, CourseID = 1, UserID = "1" }; Course_Student courseStudent2 = new Course_Student { ID = 2, CourseID = 2, UserID = "2" }; Course_Student courseStudent3 = new Course_Student { ID = 3, CourseID = 2, UserID = "3" }; Course_Student courseStudent4 = new Course_Student { ID = 4, CourseID = 1, UserID = "4" }; mock.CoursesStudents.Add(courseStudent1); mock.CoursesStudents.Add(courseStudent2); mock.CoursesStudents.Add(courseStudent3); mock.CoursesStudents.Add(courseStudent4); #endregion #region Courses Course course1 = new Course { ID = 1, Name = "Byrjenda Forritun", SchoolID = 1, Semester = "Vorönn", Year = 2013 }; Course course2 = new Course { ID = 2, Name = "Leikjaorritun", SchoolID = 2, Semester = "Haustönn", Year = 2018 }; mock.Courses.Add(course1); mock.Courses.Add(course2); #endregion #region Solutions Solution solution1 = new Solution { ID = 1, MilestoneID = 1, StudentID = "1", Code = "Hello World", SubmissionID = 1, Grade = 6.7M }; Solution solution2 = new Solution { ID = 2, MilestoneID = 3, StudentID = "2", Code = "Hello Universe", SubmissionID = 2, Grade = 7.9M }; mock.Solutions.Add(solution1); mock.Solutions.Add(solution2); #endregion #region Submissions Submission submission1 = new Submission { ID = 1, UserID = "1", MilestoneID = 1, IsAccepted = true, SolutionOutput = "Hello World", ExpectedOutput = "Hello World", Code = "cout << Hello World " }; mock.Submission.Add(submission1); #endregion #region Admins Admin admin1 = new Admin { ID = 1, UserID = "1" }; Admin admin2 = new Admin { ID = 2, UserID = "2" }; #endregion personServiceTest = new PersonService(mock); assignmentServiceTest = new AssignmentsService(mock); courseServiceTest = new CourseService(mock); solutionServiceTest = new SolutionService(mock); }