public async Task <ActionResult <Author> > Update(UpdateAuthorInput input)
 {
     try
     {
         return(await _AuthorService.UpdateAsync(input));
     }
     catch (Exception ex)
     {
         return(NotFound(ex));
     }
 }
        public async Task <Author> UpdateAsync(UpdateAuthorInput input)
        {
            try
            {
                Author oldPub = await GetAsync(input.Id);

                oldPub.Name = input.Name;
                await _context.SaveChangesAsync();

                return(oldPub);
            }
            catch (Exception err)
            {
                throw err;
            }
        }
        public Author UpdateAuthor(UpdateAuthorInput inputAuthor)
        {
            _logger.LogInformation($"Updating author (id = {inputAuthor.Id})");

            var authorEntity = _data.EfContext.Authors.Find(inputAuthor.Id);

            authorEntity.Name   = inputAuthor.Name ?? authorEntity.Name;
            authorEntity.Role   = inputAuthor.Role ?? authorEntity.Role;
            authorEntity.Link   = inputAuthor.Link ?? authorEntity.Link;
            authorEntity.WorkId = inputAuthor.WorkId ?? authorEntity.WorkId;

            _data.EfContext.Authors.Update(authorEntity);
            _data.EfContext.SaveChanges();

            _logger.LogInformation($"Author (id = {inputAuthor.Id}) is updated successfully");
            return(authorEntity);
        }
Exemple #4
0
        public void Update(UpdateAuthorInput input)
        {
            Author output = ObjectMapper.Map <Author>(input);

            _authorManager.Update(output);
        }
        public void Update(UpdateAuthorInput input)
        {
            var author = _objectMapper.Map <Author>(input);

            _authorManager.Update(author);
        }