Ejemplo n.º 1
0
        public ActionResult Index(string url)
        {
            //create the record
            var oUrl = new WutLink
            {
                RealUrl     = url,
                CreateDate  = DateTime.UtcNow,
                CreatedByIp = Request.UserHostAddress
            };

            //tag it if logged in, for posterity or cool reporting later
            if (User.Identity.IsAuthenticated)
            {
                oUrl.UserId = User.Identity.GetClaim <int>(CustomClaimTypes.UserId);
            }

            //save it
            oUrl = ShortUrlUtils.AddUrlToDatabase(oUrl, Wutcontext);

            //set it up to display
            ViewBag.ShortUrl    = ShortUrlUtils.PublicShortUrl(oUrl.ShortUrl);
            ViewBag.NavigateUrl = oUrl.RealUrl;

            //go back home
            return(View("~/Views/Home/Index.cshtml"));
        }
Ejemplo n.º 2
0
        public WutLinkPoco CreateUrl(dynamic data)
        {
            var oUrl = new WutLink
            {
                RealUrl     = data.realUrl,
                IsAzureBlob = data.isBlob,
                CreateDate  = DateTime.UtcNow,
                CreatedByIp = ((System.Web.HttpContextWrapper)Request.Properties["MS_HttpContext"]).Request.Se‌​rverVariables["HTTP_HOST"]
            };

            if (User.Identity.IsAuthenticated)
            {
                oUrl.UserId = UserId;
            }

            oUrl = ShortUrlUtils.AddUrlToDatabase(oUrl, Wutcontext);

            return(WutLinkPoco.GetPocoFromObject(oUrl));
        }