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()); } }
public string returnOriginalUrlFromShortened(string shortenedUrl) { URLShortener.Models.Url url = urls.FirstOrDefault(x => x.UrlShortened == shortenedUrl); return(url.UrlOriginal); }