public ulong ClicksOnShortURL(string shortURL) { ShortenedURL shortenedURL = GetShortenedURL(shortURL); if (shortenedURL == null) // shortened URL does not exist. { return(0); } return(shortenedURL.Clicks); }
public string Expand(string shortURL) { ShortenedURL shortenedURL = GetShortenedURL(shortURL); if (shortenedURL == null) // shortened URL does not exist. { return(string.Empty); } shortenedURL.Expanded(); return(shortenedURL.URL); }
public string Shorten(string url) { ShortenedURL shortenedURL = shortenedURLRepo.GetByURL(url); if (shortenedURL == null) // shorten this URL for the first time { shortenedURL = new ShortenedURL(url, hasher.NextHash(lastHash)); shortenedURLRepo.Save(shortenedURL); lastHash = shortenedURL.Hash; } return(FormatHashAsURL(shortenedURL.Hash)); }