public async Task <IActionResult> AddCourseAsync([FromBody] CourseAddDTO courseAddDTO) { courseAddDTO.Date = DateTime.Now; if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var result = await _service.AddCourseAsync(courseAddDTO); return(Ok(result)); }
public async Task <CourseDTO> AddCourse(CourseAddDTO course) { _repo.Add( new Course { CourseName = course.CourseName, Description = course.Description, ImageUrl = course.ImageUrl }); Course courseC = await _repo.GetSingleAsync(c => c.CourseName == course.CourseName); return(_mapper.Map <CourseDTO>(courseC)); }