public async Task<IActionResult> AddInstructor([Bind("InstructorID, InstructorFirstName, InstructorLastName, InstructorEmail, DepartmentID")]Instructor instructor) { //AddAsync adds the info to the database without freezing up the screen //database.Instructors.AddAsync(instructor); //database.SaveChangesAsync(); await instructorRepositoryInterface.AddInstructor(instructor); return RedirectToAction("ListAllInstructors"); }
public IActionResult PostInstructor(Instructor instructor) { Guid newId = new Guid(); instructor.Id = newId; _instructorRepository.AddInstructor(instructor); _instructorRepository.SaveChanges(); return(CreatedAtAction(nameof(GetInstructorById), new { id = instructor.Id }, instructor)); }
public ActionResult Create([Bind(Include = "ID,LastName,FirstMidName,HireDate")] Instructor instructor) { if (ModelState.IsValid) { instructorRepository.AddInstructor(instructor); return(RedirectToAction("Index")); } ViewBag.ID = instructorRepository.GetOfficeAssignments(instructor); return(View(instructor)); }
public async Task <IActionResult> AddInstructor ( [Bind ("InstructorID, InstructorFirstName, InstructorLastName, InstructorEmail, DepartmentID")] Instructor instructor ) { /* * database.Instructors.AddAsync(instructor); * database.SaveChangesAsync(); * */ await instructorRepositoryInterface.AddInstructor(instructor); return(RedirectToAction("ListAllInstructors")); }
public IActionResult AddInstructor(Instructor instructorToAdd) { var accessTokenAsString = JwtHelper.GetTokenSubstring(Request.Headers["Authorization"].ToString()); if (accessTokenAsString == "null") { return(Unauthorized()); } var userCredentials = JwtHelper.GetCredentialsFromToken(accessTokenAsString); var fullName = CredentialsHelper.GenerateUsername(instructorToAdd.FirstName, instructorToAdd.LastName); instructorToAdd.User.DrivingSchoolId = userCredentials.Id; var wasAddSuccessful = _instructorRepository.AddInstructor(instructorToAdd); if (wasAddSuccessful) { return(Ok()); } return(Forbid()); }
public void AddInstructor(Instructor newInstructor, IEnumerable <Category> categories) { _instructorRepository.AddInstructor(newInstructor, categories); }