示例#1
0
        /// <summary>
        ///      IsKeyValid
        /// </summary>
        /// <param name="key">   </param>
        /// <param name="system"></param>
        /// <returns></returns>
        public bool IsKeyValid(Guid key, out CIS_System system)
        {
            var systemRepo = new SystemRepository();

            system = systemRepo.SelectAllAsList().FirstOrDefault(x => x.KeyValue.ToString().Equals(key.ToString()));
            if (system == null)
            {
                return(false);
            }
            return(true);
        }
        /// <summary>
        /// CheckPassword
        /// </summary>
        /// <returns></returns>
        bool CheckKey()
        {
            var repo   = new UserAccountRepository();
            var system = new CIS_System();

            try
            {
                if (!repo.IsKeyValid(new Guid(this.input_Key.TextStringValue), out system))
                {
                    this.input_Key.SetValidation(DataValidation.Custom);
                    this.input_Key.IsValid("Invalid Key.", ErrorType.Critical);
                    return(false);
                }
            }
            catch (Exception)
            {
                return(false);
            }

            return(true);
        }
示例#3
0
        /// <summary>
        ///      RegisterAccount
        /// </summary>
        /// <param name="username"></param>
        /// <param name="password"></param>
        /// <param name="key">     </param>
        /// <returns></returns>
        public CIS_UserAccount RegisterAccount(string username, string password, Guid key)
        {
            var system = new CIS_System();

            if (!this.IsKeyValid(key, out system))
            {
                return(null);
            }

            var userAcc = new CIS_UserAccount()
            {
                UserAccountID = Guid.NewGuid(),
                Username      = username,
                Password      = password,
                Active        = true,
                CreateDate    = DateTime.Now,
                SID           = system.KeyValue.Value,
                Status        = 1
            };

            this.Insert(userAcc, true);
            return(userAcc);
        }