Exemplo n.º 1
0
 public ActionResult Create(URLShortener.Models.Url url)
 {
     try
     {
         URLShortener.Logic.URLShortenerService shortenerService = new Logic.URLShortenerService(url.UrlOriginal, null);
         string shortenedUrl = shortenerService.shortenUrl();
         url.UrlShortened = shortenedUrl;
         context.Urls.Add(url);
         context.SaveChanges();
         return(View("Index", url));
     }
     catch (Exception ex)
     {
         return(View());
     }
 }
Exemplo n.º 2
0
 public string returnOriginalUrlFromShortened(string shortenedUrl)
 {
     URLShortener.Models.Url url = urls.FirstOrDefault(x => x.UrlShortened == shortenedUrl);
     return(url.UrlOriginal);
 }