コード例 #1
0
ファイル: BetaKeys.cs プロジェクト: SuPair/vpn-2
        private string GenerateKeyAndMarkSent()
        {
            string betaKey = System.Guid.NewGuid().ToString();

            using (var db = Setup.DbFactory)
            {
                db.Open();

                var data = new LibPoco.BetaKeys(betaKey, false, true);
                db.Insert(data);
            }

            return(betaKey);
        }
コード例 #2
0
        private void BetaKeySetup()
        {
            using (var db = Setup.DbFactory)
            {
                db.Open();
                var info = db.Query <LibPoco.BetaKeys>("SELECT * FROM BetaKeys WHERE Code = @code", new { code = details.BetaKey });
                if (info.Count() != 1)
                {
                    throw new Exceptions.InvalidBetaKeyException("There appears to have been an error validating the beta key.");
                }

                betaKey = info.First();
                if (betaKey.IsUsed)
                {
                    throw new Exceptions.BetaKeyAlreadyUsedException("The beta key has already been used.");
                }
            }
        }