Пример #1
0
        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));
        }
Пример #2
0
        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));
        }
Пример #3
0
 public UriUoW(ISessionManager sessionManager, UriRepository uriRepository, ClientRepository clientRepository) :
     base(sessionManager)
 {
     m_uriRepository    = uriRepository;
     m_clientRepository = clientRepository;
 }
Пример #4
0
 public URIShortenerController(IHostingEnvironment environment)
 {
     _environment   = environment;
     _connString    = "Data Source=" + Path.GetFullPath(_environment.ContentRootPath + "/UriDB.db");
     _uriRepository = new UriRepository(_connString);
 }
Пример #5
0
 public void Instantiation()
 {
     var repo = new UriRepository();
 }