public void InsertMessageToDatabase(MessageModel message) { string sql = "insert into dbo.Messages (Message, FromUserId, ToUserId, IsRead) values " + "(@Message, @FromUserId, @ToUserId, @IsRead);"; _db.SaveData <dynamic>(sql, new { message.Message, message.FromUserId, message.ToUserId, message.IsRead }, connectionStringName); }
public bool CreateUser(string userName, string password) { bool userNameIsAvailable = IsUserNameAvailable(userName); string salt = _pwCrypto.CreateSalt(); string hashedPassword = _pwCrypto.HashPassword(password, salt); if (userNameIsAvailable) { string sql = "insert into dbo.Users (UserName, Salt, HashedPassword) values (@UserName, @Salt, @HashedPassword);"; _db.SaveData <dynamic>(sql, new { UserName = userName, Salt = salt, HashedPassword = hashedPassword }, connectionStringName); return(true); } else { return(false); } }