public async Task <IActionResult> Create([Bind("CourseId,Name,CourseDescription,TeacherId")] Course course) { if (ModelState.IsValid) { _context.Add(course); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(course)); }
public async Task <IActionResult> TimeTable(CourseViewModel timeTable) { if (ModelState.IsValid) { _context.Add(timeTable.ClassTime); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(TimeTable))); } return(View(timeTable)); }
public async Task <IActionResult> Index(BaseUserViewModel User) { if (ModelState.IsValid) { if (User.BaseUser2 != null) { _context.Add(User.BaseUser2); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } else { _context.Add(User.Student); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Student))); } } else { if (User.BaseUser2 != null) { var student = _context.users.Where(c => c.UserType.Contains("Teacher") || c.UserType.Contains("Admin")); var studentViewModel = new BaseUserViewModel() { ListUsers = student.ToList() }; return(View(studentViewModel)); } else { var student = _context.students.OrderBy(c => c.UserId); var studentViewModel = new BaseUserViewModel() { ListUsers = student.ToList() }; return(RedirectToAction(nameof(Student))); } } }