Esempio n. 1
0
        public IHttpActionResult CreateShortUrl(CreateTinyUrlRequest request)
        {
            if (request == null || string.IsNullOrWhiteSpace(request.Url))
            {
                return(BadRequest("Invalid create request"));
            }

            var inputUrl = request.Url;
            var itemId   = _dataAccess.Create(inputUrl.Trim());
            var hash     = _hahGenerator.ConvertIdToHash(itemId);
            var tinyUrl  = string.Format(_baseAddress, hash);

            return(Ok(tinyUrl));
        }