public async Task <IHttpActionResult> Get() { var instructor = await instructorService.GetAll(); var instructorDTO = instructor.Select(x => mapper.Map <InstructorDTO>(x)); return(Ok(instructorDTO)); // Status code 200 }
public async Task <IHttpActionResult> GetAll()//se devuelve un DTO { var instructors = await instructorService.GetAll(); //AutoMapper var instructorsDTO = instructors.Select(x => _mapper.Map <InstructorDTO>(x)); return(Ok(instructorsDTO)); }
public async Task <ActionResult> Create() { var instructorService = new InstructorService(new InstructorRepository(UniversityContext)); var instructors = await instructorService.GetAll(); var instructorsDTO = instructors.Select(x => mapper.Map <InstructorDTO>(x)); ViewData["Instructors"] = new SelectList(instructorsDTO, "ID", "FullName"); return(View()); }
// GET: Instructors public async Task <ActionResult> Index(int?id) { var instructorService = new InstructorService(new InstructorRepository(UniversityContext)); if (id != null) { var courses = await instructorService.GetCoursesByInstructor(id.Value); ViewBag.Courses = courses.Select(x => mapper.Map <CourseDTO>(x)); } var instructors = await instructorService.GetAll(); var instructorsDTO = instructors.Select(x => mapper.Map <InstructorDTO>(x)); return(View(instructorsDTO)); }
public async Task <ActionResult> Create(OfficeAssignmentDTO officeAssignmentDTO) { var instructorService = new InstructorService(new InstructorRepository(UniversityContext)); var instructors = await instructorService.GetAll(); var instructorsDTO = instructors.Select(x => mapper.Map <InstructorDTO>(x)); ViewData["Instructors"] = new SelectList(instructorsDTO, "ID", "FullName", officeAssignmentDTO.InstructorID); if (ModelState.IsValid) { var officeAssignmentService = new OfficeAssignmentService(new OfficeAssignmentRepository(UniversityContext)); var officeAssignment = mapper.Map <OfficeAssignment>(officeAssignmentDTO); officeAssignment = await officeAssignmentService.Insert(officeAssignment); return(RedirectToAction("Index", "OfficeAssignments")); } return(View(officeAssignmentDTO)); }