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); }
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)); }
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); }
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()); }
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); }