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()); }
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()); }
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()); }