Beispiel #1
0
        public IActionResult Create()
        {
            string url        = Request.Form["url"];
            bool   isValidUrl = Uri.IsWellFormedUriString(url, UriKind.Absolute);

            if (isValidUrl)
            {
                Link GeneratedLink = repo.CreateShortUrl(url);
                return(Json(new UrlViewModel(GeneratedLink, Url.RouteUrl("homepage", null, Request.Scheme))));
            }
            return(BadRequest());
        }
Beispiel #2
0
        public IActionResult Generate([FromBody] UrlCreationEntity url)
        {
            Link GeneratedLink = repo.CreateShortUrl(url.url);

            return(Json(new UrlViewModel(GeneratedLink, Url.RouteUrl("homepage", null, Request.Scheme))));
        }