Exemple #1
0
        private void B_SetKey_Click(object sender, EventArgs e)
        {
            Dialogs.PressKeyDialog dlg = new PressKeyDialog();
            DialogResult           res = dlg.ShowDialog();

            if (res == DialogResult.OK)
            {
                this.ReturnKey   = dlg.ReturnedKey;
                this.TB_Key.Text = ReturnKey.ToString();
            }
        }
Exemple #2
0
        public void ShouldGetAndSeReturnKeytProperties()
        {
            var          textBox     = new TextBox();
            const string defaultText = "Default Text";

            var command = new MockCommand();

            ReturnKey.SetCommand(textBox, command);
            Assert.AreEqual(command, ReturnKey.GetCommand(textBox));

            ReturnKey.SetDefaultTextAfterCommandExecution(textBox, defaultText);
            Assert.AreEqual(defaultText, ReturnKey.GetDefaultTextAfterCommandExecution(textBox));
        }
Exemple #3
0
        public ReturnKey Post([FromBody] Signin signin)
        {
            var rtnKey = new ReturnKey();

            if (signin?.UserName != null && signin.Password != null)
            {
                var salt = (from i in _db.TbSubscriptions
                            where string.Equals(i.Email, signin.UserName, StringComparison.CurrentCultureIgnoreCase)
                            select i.Salt).FirstOrDefault();

                var subscription = (from i in _db.TbSubscriptions
                                    where i.SubscriptionStatusId == 2 && i.Email == signin.UserName && i.Password == Security.EncryptPassword(signin.Password, salt)
                                    select i).FirstOrDefault();

                if (subscription != null)
                {
                    var token = (from i in _db.TbSubscriptionTokens
                                 where i.Email == subscription.Email && i.ExpiresOn > DateTime.Now
                                 select i).FirstOrDefault();
                    if (token == null)
                    {
                        double.TryParse(_configuration["Setting:AuthTokenExpiry"], out var authTokenExpiry);

                        token = new TbSubscriptionTokens
                        {
                            Email     = subscription.Email,
                            AuthToken = Guid.NewGuid().ToString(),
                            IssuedOn  = DateTime.Now,
                            ExpiresOn = DateTime.Now.AddSeconds(authTokenExpiry)
                        };

                        _db.TbSubscriptionTokens.Add(token);
                        _db.SaveChanges();
                    }

                    rtnKey.UID       = subscription.UniqueId.ToString();
                    rtnKey.AuthToken = token.AuthToken;
                    rtnKey.Message   = "success!!!";
                    rtnKey.Role      = subscription.GroupId;
                }
                else
                {
                    rtnKey.Message = _localizer["NotValid"];
                }
            }
            else
            {
                rtnKey.Message = _localizer["NotValid"];
            }
            return(rtnKey);
        }
Exemple #4
0
 public void ShouldThrowExceptionInSetDefaultTextAfterCommandExecutionIfTextboxIsNull()
 {
     ReturnKey.SetDefaultTextAfterCommandExecution(null, "Some Text");
 }
Exemple #5
0
 public void ShouldThrowExceptionInGetDefaultTextAfterCommandExecutionIfTextboxIsNull()
 {
     ReturnKey.GetDefaultTextAfterCommandExecution(null);
 }
Exemple #6
0
 public void ShouldThrowExceptionInSetCommandIfTextboxIsNull()
 {
     ReturnKey.SetCommand(null, new MockCommand());
 }
Exemple #7
0
 public void ShouldThrowExceptionInGetCommandIfTextboxIsNull()
 {
     ReturnKey.GetCommand(null);
 }