コード例 #1
0
ファイル: ApiService.cs プロジェクト: ApiNetworks/iAFWeb
        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
ファイル: ApiService.cs プロジェクト: ApiNetworks/iAFWeb
        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
ファイル: UrlServiceTests.cs プロジェクト: ApiNetworks/iAFWeb
        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
ファイル: UrlController.cs プロジェクト: ApiNetworks/iAFWeb
        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
ファイル: UrlServiceTests.cs プロジェクト: ApiNetworks/iAFWeb
        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
ファイル: UrlServiceTests.cs プロジェクト: ApiNetworks/iAFWeb
        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
ファイル: UrlServiceTests.cs プロジェクト: ApiNetworks/iAFWeb
        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);
        }