public IActionResult Create(CourseViewModel model) { if (ModelState.IsValid) { var courses = CourseMapper.SerializeCourse(model); _repository.CreateCourse(courses); return(PartialView("_CourseSuccessPartial")); } return(PartialView("_CourseCreateModelPartial", model)); }
public ActionResult <CourseReadDto> CreateCourse(CourseCreateDto courseCreateDto) { var courseModel = _mapper.Map <Course>(courseCreateDto); _repository.CreateCourse(courseModel); _repository.SaveChanges(); var courseReadDto = _mapper.Map <CourseReadDto>(courseModel); return(CreatedAtRoute(nameof(GetCourseById), new { CourseID = courseReadDto.CourseId }, courseReadDto)); }