示例#1
0
        public object ExpandUrl(UrlRequest request)
        {
            if (!request.ShortId.IsShortCode())
                throw new ArgumentNullException(request.ShortId);

            UrlService service = new UrlService();
            var dbResponse = service.ExpandUrl(request.ShortId);
            return Mapper.MapResponse(dbResponse);
        }
示例#2
0
        public object ExpandUrl(UrlRequest request)
        {
            if (!request.ShortId.IsShortCode())
            {
                throw new ArgumentNullException(request.ShortId);
            }

            UrlService service    = new UrlService();
            var        dbResponse = service.ExpandUrl(request.ShortId);

            return(Mapper.MapResponse(dbResponse));
        }
示例#3
0
        public void Test_Get_Item_By_LongId()
        {
            UrlService service = new UrlService();

            Stopwatch stopwatch = new Stopwatch();

            // Begin timing
            stopwatch.Start();

            Url url = service.ExpandUrl(((ulong)45).EncodeBase58());

            // Stop timing
            stopwatch.Stop();

            // Write result
            string response = stopwatch.Elapsed.TotalMilliseconds.ToString();

            Assert.Inconclusive(response);
        }
示例#4
0
        public ActionResult Ad(string id)
        {
            if (id.IsShortCode())
            {
                UrlService urlService = new UrlService();
                Url        entity     = urlService.ExpandUrl(id);
                if (entity != null && !String.IsNullOrEmpty(entity.Href))
                {
                    UrlPageModel model = new UrlPageModel();
                    model.UrlModel = Mapper.Map(entity);
                    return(View(model));
                }
                else
                {
                    throw new HttpException();
                }
            }

            return(View());
        }
示例#5
0
        public void Test_Get_Items_By_ShortId()
        {
            UrlService service = new UrlService();

            Stopwatch stopwatch = new Stopwatch();

            // Begin timing
            stopwatch.Start();

            Parallel.For(0, 1000, i =>
            {
                Url url = service.ExpandUrl(i.ToString());
            });

            // Stop timing
            stopwatch.Stop();

            // Write result
            string response = stopwatch.Elapsed.TotalMilliseconds.ToString();

            Assert.Inconclusive(response);
        }
示例#6
0
        public void Test_Get_Items_By_ShortId()
        {
            UrlService service = new UrlService();

            Stopwatch stopwatch = new Stopwatch();

            // Begin timing
            stopwatch.Start();

            Parallel.For(0, 1000, i =>
            {
                Url url = service.ExpandUrl(i.ToString());
            });

            // Stop timing
            stopwatch.Stop();

            // Write result
            string response = stopwatch.Elapsed.TotalMilliseconds.ToString();

            Assert.Inconclusive(response);
        }
示例#7
0
        public void Test_Get_Item_By_LongId()
        {
            UrlService service = new UrlService();

            Stopwatch stopwatch = new Stopwatch();

            // Begin timing
            stopwatch.Start();

            Url url = service.ExpandUrl(((ulong)45).EncodeBase58());

            // Stop timing
            stopwatch.Stop();

            // Write result
            string response = stopwatch.Elapsed.TotalMilliseconds.ToString();

            Assert.Inconclusive(response);
        }