コード例 #1
0
        public ActionResult Create(Instructor instructor)
        {
            _service.CreateInstructor(instructor);
            var newInstructor = _service.GetInstructorByName(instructor.FirstName, instructor.LastName).FirstOrDefault();

            return(View("Detail", newInstructor.Id));
        }
コード例 #2
0
        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));
     }
 }
コード例 #5
0
 public HttpResponseMessage Create(Instructor instructor)
 {
     _instructorService.CreateInstructor(instructor);
     return(Request.CreateResponse(HttpStatusCode.OK, instructor));
 }