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)); }
public EfCreateAuthorCommand(BookStoreContext context, CreateAuthorValidator validator, IMapper mapper) { _context = context; _validator = validator; _mapper = mapper; }
public EfCreateAuthorCommand(BookstoreContext context, CreateAuthorValidator validator) { _context = context; _validator = validator; }