public bool Add(string link, string token) { var guid = new Guid(); var url = new URL { Created = DateTime.Now, Guid = guid.ToString(), Link = link, Token = token }; _context.URL.Add(url); return(_context.SaveChanges() == 1); }
public IActionResult Index([FromRoute] string token) { if (string.IsNullOrEmpty(token)) { return(View()); } var url = _context.URL.ToList().FirstOrDefault(x => x.Token == token); if (url == null) { return(View()); } url.Clicked++; _context.SaveChanges(); return(Redirect(url.Link)); }