Ejemplo n.º 1
0
        public ActionResult <AuthorDto> UpdateAuthor(string authorId, AuthorForUpdate model)
        {
            var authorFromRepo = _courseLibraryRepository.GetAuthor(ObjectId.Parse(authorId));

            if (authorFromRepo == null)
            {
                return(NotFound());
            }
            _mapper.Map(model, authorFromRepo);

            _courseLibraryRepository.UpdateAuthor(ObjectId.Parse(authorId), authorFromRepo);

            return(Ok(_mapper.Map <AuthorDto>(authorFromRepo)));
        }
        public async Task <IActionResult> UpdateAuthor(Guid authorId, AuthorForUpdateDto authorForUpdateDto)
        {
            var authorFromRepo = await _courseLibraryRepository.GetAuthorAsync(authorId);

            if (authorFromRepo == null)
            {
                return(NotFound());
            }

            //copiem valorile editate peste valorile entitatii
            _mapper.Map(authorForUpdateDto, authorFromRepo);

            _courseLibraryRepository.UpdateAuthor(authorFromRepo);
            await _courseLibraryRepository.SaveAsync();

            return(NoContent());
        }