Exemplo n.º 1
0
        public ActionResult ViewHistory(int id)
        {
            ViewBag.Url = Request.Url.AbsoluteUri.Replace(Request.Url.PathAndQuery, "");
            var repo = new UrlRepo(Properties.Settings.Default.ConStr);

            return(View(repo.GetUrlsByUser(id)));
        }
Exemplo n.º 2
0
        public ActionResult NewShortUrl(int id, string url)
        {
            ViewBag.Url = Request.Url.AbsoluteUri.Replace(Request.Url.PathAndQuery, "");
            var repo   = new UrlRepo(Properties.Settings.Default.ConStr);
            var newUrl = repo.ShortenUrl(url, id);

            return(Json(new
            {
                Id = newUrl.Id,
                ShortUrl = $"{ViewBag.Url}/{newUrl.ShortUrl}",
                RealUrl = newUrl.RealUrl,
            }));
        }
Exemplo n.º 3
0
        private bool SaveToStore(string originalUrl, string shortenedUrl, DateTime now)
        {
            UrlRepo repo = new UrlRepo();

            return(repo.SaveToStore(originalUrl, shortenedUrl, now));
        }
Exemplo n.º 4
0
        public string GetOriginalUrl(string shortKey)
        {
            UrlRepo repo = new UrlRepo();

            return(repo.GetOriginalUrlByKey(shortKey));
        }
Exemplo n.º 5
0
 public MakeTinyUrlService(UserRepo userRepo, UrlRepo urlRepo)
 {
     _urlRepo  = urlRepo;
     _userRepo = userRepo;
 }
Exemplo n.º 6
0
        public ActionResult LinkToTheWebSite(string shortUrl)
        {
            var repo = new UrlRepo(Properties.Settings.Default.ConStr);

            return(Redirect(repo.GetRealUrl(shortUrl)));
        }