public ActionResult Minify(String url) { using (var db = new bitContext()) { BitUrl nUrl = new BitUrl() { appendDate = DateTime.Now, author = db.Users.Find(Session.currentUserID()), longUrl = url.Trim() }; db.Urls.Add(nUrl); db.SaveChanges(); return(PartialView("~/Views/Home/_UrlResult.cshtml", nUrl)); } }
public ActionResult Click(string urlId) { using (var db = new bitContext()) { long id = MvcApplication.Minificator.Maxify(urlId); BitUrl bu = db.Urls.Find(id); if (bu != null) { bu.clicks++; db.SaveChanges(); return(new RedirectResult(bu.longUrl)); } } return(RedirectToAction("Notfound")); }