public CourseDto CreateCourse(CreateCourseDto createCourseDto, string currentUserId) { CreateCourseValidator authorValidator = new CreateCourseValidator(); if (!authorValidator.Validate(createCourseDto).IsValid) { throw new Exception("Check_Your_Fileds"); } Course course = _mapper.Map <CreateCourseDto, Course>(createCourseDto); course.CreatedOn = DateTime.Now; course.CreatedBy = currentUserId; _unitOfWork.CourseRepository.Add(course); _unitOfWork.Save(); return(_mapper.Map <Course, CourseDto>(course)); }
public AuthorDto CreateAuthor(CreateAuthorDto createAuthor, string currentUserId) { CreateAuthorValidator authorValidator = new CreateAuthorValidator(); if (!authorValidator.Validate(createAuthor).IsValid) { throw new Exception("Empty_Null"); } Author author = _mapper.Map <CreateAuthorDto, Author>(createAuthor); author.CreatedOn = DateTime.Now; author.CreatedBy = currentUserId; _unitOfWork.AuthorRepository.Add(author); _unitOfWork.Save(); return(_mapper.Map <Author, AuthorDto>(author)); }