public ActionResult Shortened(LocationModel location) { var repo = (UriRepository)Session["repo"]; if (repo == null) { repo = new UriRepository(); } var uri = new UriModel(new Helpers.Utility(), location.FullURI, location.ConfirmationCode); repo.Add(uri); uri = repo.Get(uri.ShortURI); // if uri already exists, use original confirmation token, etc. Session["repo"] = repo; return(View(nameof(Shortened), uri.Location)); }
public ActionResult Index() { ViewBag.Title = "UrlShortener"; // TODO: instantiate a repository // add something to it for testing // store the repository in a Session variable // UGH SESSION VARS var repo = new UriRepository(); var uri = new UriModel(new Helpers.Utility(), "http://www.michaelpaulukonis.com"); // TODO: controller's dependencies should be mocked! repo.Add(uri); Session["repo"] = repo; var location = new LocationModel(); return(View(location)); }
public UriUoW(ISessionManager sessionManager, UriRepository uriRepository, ClientRepository clientRepository) : base(sessionManager) { m_uriRepository = uriRepository; m_clientRepository = clientRepository; }
public URIShortenerController(IHostingEnvironment environment) { _environment = environment; _connString = "Data Source=" + Path.GetFullPath(_environment.ContentRootPath + "/UriDB.db"); _uriRepository = new UriRepository(_connString); }
public void Instantiation() { var repo = new UriRepository(); }