public ActionResult Create(Instructor instructor) { _service.CreateInstructor(instructor); var newInstructor = _service.GetInstructorByName(instructor.FirstName, instructor.LastName).FirstOrDefault(); return(View("Detail", newInstructor.Id)); }
public ActionResult Create(InstructorDetailsViewModel model) { var instructor = Mapper.Map <InstructorDetailsViewModel, Instructor>(model); _instructorService.CreateInstructor(instructor); var assignedCourses = model.Courses.Where(x => x.IsChecked).Select(x => x.Id).ToList(); assignedCourses.ForEach(c => _courseInstructorService.AssignInstructorToCourse(instructor.Id, c)); return(RedirectToAction("Index")); }
public IHttpActionResult Create(InstructorWithCoursesIn instructorWithCoursesIn) { if (instructorWithCoursesIn == null) { return(new Helpers.ActionResultBuilder .CreateActionResult <InstructorWithCoursesIn>(Request, null, System.Net.HttpStatusCode.BadRequest)); } else { _instructorService.CreateInstructor(instructorWithCoursesIn); return(new Helpers.ActionResultBuilder .CreateActionResult <InstructorWithCoursesIn>(Request, instructorWithCoursesIn, System.Net.HttpStatusCode.OK)); } }
public IHttpActionResult Create([System.Web.Mvc.Bind(Include = "Id,LastName,FirstName,HireDate,Courses")] InstructorWithCoursesIn instructorWithCoursesIn) { if (instructorWithCoursesIn == null) { return(new Helpers.ActionResultBuilder .CreateActionResult <InstructorWithCoursesIn>(Request, null, System.Net.HttpStatusCode.BadRequest)); } else { _instructorService.CreateInstructor(instructorWithCoursesIn); return(new Helpers.ActionResultBuilder .CreateActionResult <InstructorWithCoursesIn>(Request, instructorWithCoursesIn, System.Net.HttpStatusCode.OK)); } }
public HttpResponseMessage Create(Instructor instructor) { _instructorService.CreateInstructor(instructor); return(Request.CreateResponse(HttpStatusCode.OK, instructor)); }