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