public void TestConversion() { long a = 99111234; var ans = DataConvertor.ToBaseN(a); var b = DataConvertor.ToLongN(ans); Assert.AreEqual(a, b); }
public ActionResult <UrlEntity> Post([FromBody] string longUrl) { var shortIdCounter = Global.GetCounter(); var shortId = long.Parse(Global.Prefix + "" + shortIdCounter); var shortUrl = DataConvertor.ToBaseN(shortId); var mongoUrlEntity = _tinyUrlRepository.PostLongUrl(new MongoUrlEntity() { LongUrl = longUrl, ShortUrlId = new BsonInt64(shortId), ServerPrefix = Global.Prefix }); var urlEntity = new UrlEntity() { LongUrl = longUrl, ShortUrl = shortUrl }; return(urlEntity); }