public IActionResult Show(int?id)
        {
            if (!id.HasValue)
            {
                return(NotFound());
            }

            var shorturl = _service.GetById(id.Value);

            if (shorturl == null)
            {
                return(NotFound());
            }

            var shortenedUrl = ReBaser.Encode(shorturl.Id);

            return(Accepted(new { shortenUrl = shortenedUrl }));
        }
        public IActionResult Create(string originalUrl)
        {
            Console.WriteLine(originalUrl);
            Regex rgx = new Regex("(http[s]?:\\/\\/)[^\\s([\"<,>]*\\.[^\\s[\\\",><]*");

            if (rgx.IsMatch(originalUrl))
            {
                var shortUrl = new ShortUrl
                {
                    OriginalUrl = originalUrl
                };

                _service.save(shortUrl);
                Console.WriteLine("GotIt");
                return(Created("/ShortUrl/Create", new { id = ReBaser.Encode(shortUrl.Id) }));
            }
            return(Conflict());
        }
 public ShortUrl GetByPath(string path)
 {
     return(_context.ShortUrls.Find(ReBaser.Decode(path)));
 }