Ejemplo n.º 1
0
        public static UrlResult CreateUrlResult(HostString host, UrlEntry entry)
        {
            var shortUrl = $"{host.Value}/api/{entry.Key.Value}";

            return(new UrlResult {
                ShortUrl = shortUrl, LongUrl = entry.Url
            });
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Add URL to database and return a UrlResult that contains both the original and short URL.
        /// HostString is used to build full short URL.
        /// </summary>
        public Result <UrlResult> AddUrlKey(HostString host, string url)
        {
            var result = UrlEntry
                         .CreateFromUrl(8, url)
                         .Then(DataService.AddShortUrl)
                         .Then(entry => CreateUrlResult(host, entry));

            return(result);
        }