public ActionResult Create(Course course, int DepartmentId) { _db.Courses.Add(course); _db.CourseDepartment.Add(new CourseDepartment() { DepartmentId = DepartmentId, CourseId = course.CourseId }); _db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Create(Course course, int StudentId) { _db.Courses.Add(course); // if (StudentId != 0) // { // _db.CourseStudent.Add(new CourseStudent() { CourseId = course.CourseId, StudentId = StudentId }); // } _db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Create(Student student, int CourseId) { _db.Students.Add(student); if (CourseId != 0) { _db.CourseStudent.Add(new CourseStudent() { CourseId = CourseId, StudentId = student.StudentId }); } _db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit(Student student, int CourseId) { if (CourseId != 0) { _db.StudentCourse.Add(new StudentCourse() { CourseId = CourseId, StudentId = student.StudentId }); } _db.Entry(student).State = EntityState.Modified; _db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Create(Course course, int StudentId) { _db.Courses.Add(course); if (StudentId != 0) { _db.StudentCourse.Add(new StudentCourse() { StudentId = StudentId, CourseId = course.CourseId }); } _db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Create(Student student, int[] CourseId) { _db.Students.Add(student); if (CourseId.Length != 0) { foreach (int id in CourseId) { _db.StudentsCourses.Add(new StudentCourse() { CourseId = id, StudentId = student.StudentId }); } } _db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Create(Course course, int[] DepartmentId) { _db.Courses.Add(course); if (DepartmentId.Length != 0) { foreach (int id in DepartmentId) { _db.CoursesDepartments.Add(new CourseDepartment() { CourseId = course.CourseId, DepartmentId = id }); } } /*if(DepartmentId!=0) * { * _db.CoursesDepartments.Add(new CourseDepartment() { CourseId = course.CourseId, DepartmentId = DepartmentId}); * }*/ _db.SaveChanges(); return(RedirectToAction("Index")); }
public async Task <ActionResult> Create(Student student, int CourseId, int DepartmentId) { var userId = this.User.FindFirst(ClaimTypes.NameIdentifier)?.Value; var currentUser = await _userManager.FindByIdAsync(userId); student.User = currentUser; _db.Students.Add(student); if (CourseId != 0) { _db.CourseStudent.Add(new CourseStudent() { CourseId = CourseId, StudentId = student.StudentId }); _db.DepartmentStudent.Add(new DepartmentStudent() { DepartmentId = DepartmentId, StudentId = student.StudentId }); } _db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Create(Department department, int DepartmentId) { _db.Departments.Add(department); _db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Create(Student student) { _db.Students.Add(student); _db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Create(Course course) { _db.Courses.Add(course); _db.SaveChanges(); return(RedirectToAction("Details", new { id = course.CourseId })); }
public ActionResult Create(Course course) { _db.Courses.Add(course); _db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit(StudentCourse sc) { _db.Entry(sc).State = EntityState.Modified; _db.SaveChanges(); return(RedirectToAction("Details", "Courses", new { id = sc.CourseId })); }
public ActionResult Create(Department department) { _db.Departments.Add(department); _db.SaveChanges(); return(RedirectToIndex("Details", new { id = department.DepartmentId })); }
public ActionResult Create(Student student) { _db.Students.Add(student); _db.SaveChanges(); return(RedirectToAction("Details", new { id = student.StudentId })); }