예제 #1
0
        public async Task <IActionResult> UpdateLink(Guid id, LinkToUpdateDto activity)
        {
            var linkEntity = await _repo.GetLinkAsync(id);

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

            _mapper.Map(activity, linkEntity);
            _repo.UpdateLink(linkEntity);
            await _repo.SaveChangesAsync();

            return(NoContent());
        }
예제 #2
0
        public async Task <IActionResult> UpdateLink(Guid id, LinkToUpdateDto link)
        {
            var linkEntity = await _linksRepo.GetLinkAsync(id);

            if (linkEntity == null)
            {
                return(NotFound());
            }
            _mapper.Map(link, linkEntity);
            _linksRepo.UpdateLink(linkEntity);

            // It might be more proper to handle this error in the repository
            try
            {
                await _linksRepo.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException) when(!_linksRepo.LinkExists(id))
            {
                return(NotFound());
            }
            return(NoContent());
        }