Exemplo n.º 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);
        }
Exemplo n.º 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));
        }
Exemplo n.º 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);
        }
Exemplo n.º 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());
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }