コード例 #1
0
        public IActionResult UpdateLink([FromQuery] int orderId, [FromQuery] int productId, [FromQuery] int count)
        {
            var link = _linksRepository.GetLinkByIds(orderId, productId);

            if (link is null)
            {
                return(NotFound());
            }
            _linksRepository.UpdateLink(orderId, productId, count);
            return(Ok());
        }
コード例 #2
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());
        }
コード例 #3
0
ファイル: LinksController.cs プロジェクト: dwalleck/Zelda
        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());
        }