Exemplo n.º 1
0
        public async Task <ActionResult> Put(int id, AuthorUpsertDto authorUpsertDto)
        {
            await _authorService.UpdateAuthor(id, authorUpsertDto);

            _logger.LogInformation(LogMessages.EntityUpdated);
            return(Ok());
        }
Exemplo n.º 2
0
        public async Task <ActionResult> Post(AuthorUpsertDto authorUpsertDto)
        {
            var authorReadDto = await _authorService.CreateAuthorReadDto(authorUpsertDto);

            _logger.LogInformation(LogMessages.EntityCreated);
            return(CreatedAtAction(nameof(Get), new { authorReadDto.Id }, authorReadDto));
        }
Exemplo n.º 3
0
        public async Task MapPatch(Author author, AuthorUpsertDto dto)
        {
            _mapper.Map(dto, author);
            await _unitOfWork.Authors.Update(author);

            await _unitOfWork.Save();
        }
Exemplo n.º 4
0
        public async Task UpdateAuthor(int id, AuthorUpsertDto authorUpsertDto)
        {
            var author = await FindAuthor(id);

            _mapper.Map(authorUpsertDto, author);
            await _unitOfWork.Authors.Update(author);

            await _unitOfWork.Save();
        }
Exemplo n.º 5
0
        public async Task <AuthorReadDto> CreateAuthorReadDto(AuthorUpsertDto authorUpsertDtoDto)
        {
            var author = _mapper.Map <Author>(authorUpsertDtoDto);
            await _unitOfWork.Authors.Create(author);

            await _unitOfWork.Save();

            return(_mapper.Map <AuthorReadDto>(author));
        }