public async Task <ApiResponse <Course> > CreateCourse(CourseDto courseDto) { var response = new ApiResponse <Course>(); try { //check course Exists var isExistCourse = await _courseRepository.CountAsync(i => i.Name == courseDto.Name); if (isExistCourse != 0) { response.Success = false; response.Errors.Add("Course Already Exists"); return(response); } var id = Guid.NewGuid(); //create new course var course = Mapper.Map <Course>(courseDto); course.Id = id; //course.CreatedBy = course.Id; course.CreatedDate = DateTime.Now; //course.Roles = courseRoles; course.IsActive = true; await _courseRepository.AddAsyn(course); response.Success = true; } catch (Exception ex) { response.Success = false; response.Errors.Add(ex.Message); } return(response); }