Пример #1
0
        private bool checkUser()
        {
            bool retVal = true;

            using (var db = new CroceRossaEntities())
            {
                Usr usr = db.Usr.FirstOrDefault(x => x.UsrNam.Equals(UserTextBox.Text.ToString()));
                if (usr == null)
                {
                    retVal = false;
                }
                else
                {
                    if (KriptoEntity.DecryptString(usr.UsrPsw) != PasswordBox.Password.ToString())
                    {
                        retVal = false;
                    }
                    else
                    {
                        GlobalInfo.LoggedUser = usr.toUserEntity();
                    }
                }
            }

            return(retVal);
        }
Пример #2
0
        public static Usr toUsr(this UserEntity user, Usr usr = null)
        {
            if (usr == null)
            {
                usr = new Usr();
            }

            usr.UsrOwnId = user.Id;
            usr.UsrNam   = user.AccountName;
            usr.UsrPsw   = KriptoEntity.EncryptString(user.Password);
            usr.UsrTyp   = user.UserType.ToString();
            return(usr);
        }
Пример #3
0
        public static UserEntity toUserEntity(this Usr usr)
        {
            UserEntity user;

            if (usr == null)
            {
                return(new UserEntity());
            }
            else
            {
                user = new UserEntity(usr.UsrOwnId, usr.UsrNam, KriptoEntity.DecryptString(usr.UsrPsw), usr.UsrTyp[0]);
            }

            return(user);
        }