本文整理汇总了C#中IUser.hashedPassword方法的典型用法代码示例。如果您正苦于以下问题:C# IUser.hashedPassword方法的具体用法?C# IUser.hashedPassword怎么用?C# IUser.hashedPassword使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IUser
的用法示例。
在下文中一共展示了IUser.hashedPassword方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: createOrUpdateUser
public bool createOrUpdateUser(IUser user)
{
using (var conn = new SQLiteConnection(ConfigurationManager.ConnectionStrings["PRIMARY_DB"].ConnectionString))
{
conn.Open();
using (var cmd = conn.CreateCommand())
{
if (user.Id.HasValue)
{
cmd.CommandText = "UPDATE users SET name=:name, password=:password,facialdescription:facialdescription WHERE id=:userId LIMIT 1";
var userId = cmd.CreateParameter();
userId.DbType = DbType.Int64;
userId.Direction = ParameterDirection.Input;
userId.IsNullable = false;
userId.ParameterName = "userId";
userId.Value = user.Id.Value;
cmd.Parameters.Add(userId);
}
else
{
cmd.CommandText = "INSERT INTO users(name, password) VALUES(:name, :password, :facialdescription)";
}
var name = cmd.CreateParameter();
name.DbType = DbType.String;
name.Direction = ParameterDirection.Input;
name.IsNullable = false;
name.ParameterName = "name";
name.Value = user.Name;
cmd.Parameters.Add(name);
var password = cmd.CreateParameter();
password.DbType = DbType.String;
password.Direction = ParameterDirection.Input;
password.IsNullable = false;
password.ParameterName = "password";
password.Value = user.hashedPassword();
cmd.Parameters.Add(password);
var facial = cmd.CreateParameter();
facial.DbType = DbType.Xml;
facial.Direction = ParameterDirection.Input;
facial.ParameterName = "facialdescription";
facial.Value = user.FacialDescription;
cmd.Parameters.Add(facial);
if (user.Id.HasValue)
cmd.ExecuteNonQuery();
else
user.Id =(long)cmd.ExecuteScalar();
}
conn.Close();
}
return true;
}
示例2: isUser
public IUser isUser(IUser user)
{
using (
var conn = new SQLiteConnection(ConfigurationManager.ConnectionStrings["PRIMARY_DB"].ConnectionString))
{
conn.Open();
using (var cmd = conn.CreateCommand())
{
cmd.CommandText = "SELECT * FROM users WHERE id=:userID AND password=:password LIMIT 1";
var userId = cmd.CreateParameter();
userId.DbType = DbType.Int64;
userId.Direction = ParameterDirection.Input;
userId.IsNullable = false;
userId.ParameterName = "userId";
userId.Value = user.Id.Value;
userId.DbType = DbType.String;
userId.Direction = ParameterDirection.Input;
userId.IsNullable = false;
userId.ParameterName = "password";
userId.Value = user.hashedPassword();
cmd.Parameters.Add(userId);
using (var reader = cmd.ExecuteReader(CommandBehavior.SingleRow))
{
// reader["facialdescription"];
}
}
}
return null;
}