public async Task <LinkShortDTO> CreateLink(string link, string clientKey) { var clientId = (await _clientRepository.FirstOrDefaultAsync(x => x.ClientKey == clientKey))?.Id ?? 0; if (clientId == 0) { clientId = await AddClient(clientKey); } var linkObj = new Link { ClientId = clientId, CreationDate = DateTime.Now, OriginalLink = link, Id = _idGenerator.GetId() }; await _linkRepository.CreateAsync(linkObj); return(new LinkShortDTO { OriginalLink = link, Hash = linkObj.Id, ShortLink = _preferences.CurrentDomain + linkObj.Id }); }