Example #1
0
        public AuthorDto UpdateAuthor(AuthorDto authorDto, string currentUserId)
        {
            UpdateAuthorValidator authorValidator = new UpdateAuthorValidator();

            if (!authorValidator.Validate(authorDto).IsValid)
            {
                throw new Exception("Empty_Null");
            }
            Author author = _unitOfWork.AuthorRepository.GetById(authorDto.AuthorId);

            if (author == null)
            {
                throw new Exception("Not_Found");
            }
            author.AuthorName = authorDto.AuthorName;
            author.UpdateOn   = DateTime.Now;
            author.UpdateBy   = currentUserId;
            _unitOfWork.AuthorRepository.Update(author);
            _unitOfWork.Save();
            return(_mapper.Map <Author, AuthorDto>(author));
        }
Example #2
0
 public EfUpdateAuthorCommand(BookStoreContext context, IMapper mapper, UpdateAuthorValidator validator)
 {
     _context   = context;
     _mapper    = mapper;
     _validator = validator;
 }
 public EfUpdateAuthorCommand(BookstoreContext context, UpdateAuthorValidator validator)
 {
     _context   = context;
     _validator = validator;
 }