public IActionResult Index() { ViewBag.Title = "Url Shortener"; ShortenViewModel model = new ShortenViewModel(); return(View(model)); }
public IActionResult Index(ShortenViewModel shortenViewModel) { // In the real world I'd call a service that would: // 1. Clean the URL to remove unnecessary parameters // 2. Shorten the URL (Shorten.GenerateCode) // 3. Check if code already exists in the DB // 4. Insert new code + original URL in the DB shortenViewModel.ShortenUrl = $"https://cor.to/{Shorten.GenerateCode(8)}"; return(View(shortenViewModel)); }
public ActionResult Index() { ViewBag.Title = "Url Shortener - " + Config.Title; ShortenViewModel model = new ShortenViewModel(); return View(model); }