public async Task <Link> Create(string clientId, string url) { var link = await _linksRepository.GetByUrl(clientId, url); if (link != null) { link.ShortUrl = getShortUrl(); await _linksRepository.Update(link); return(link); } var newLink = new Link(clientId, url, getShortUrl()); await _linksRepository.Insert(newLink); return(link); }