Example #1
0
        public Shortener(string url)
        {
            var urls = new LiteDatabase(@"Filename=URL_DATABASE.db; Connection=shared").GetCollection <ZavorURL>();

            _url = new ZavorURL()
            {
                Token = GenerateToken(), URL = url, ShortenedURL = _baseUrl + Token
            };
            if (urls.Exists(u => u.URL == url))
            {
                throw new Exception("URL already exists");
            }
            urls.Insert(_url);
        }