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); }
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); }
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); }