public async Task <IActionResult> Create([Bind("Id,Name,Email")] Student student) { if (ModelState.IsValid) { _context.Add(student); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(student)); }
public async Task <IActionResult> Create([Bind("Id,Name,MobileNumber,Email")] Tutor tutor) { if (ModelState.IsValid) { _context.Add(tutor); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(tutor)); }
public async Task <IActionResult> Create([Bind("TutorId,BookingDate")] BookingRequest bookingRequest) { var student = (from stu in _context.Student where stu.Email.Equals(User.Identity.Name) select stu).FirstOrDefault(); if (ModelState.IsValid) { bookingRequest.StudentId = student.Id; _context.Add(bookingRequest); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["TutorId"] = new SelectList(_context.Set <Tutor>(), "Id", "Name", bookingRequest.TutorId); return(View(bookingRequest)); }