public void AddPost(PostDetails post) { using (var connection = new SqlConnection(connectionString)) { using (SqlCommand cmd = connection.CreateCommand()) { connection.Open(); cmd.CommandText = @"INSERT INTO [dbo].[BlogPost] ([Id] ,[CreateDate] ,[Text] ,[Title]) VALUES (@id ,@createDate ,@text ,@title)"; cmd.CommandType = CommandType.Text; cmd.Parameters.Add("@id", SqlDbType.UniqueIdentifier).Value = post.Id; cmd.Parameters.Add("@createDate", SqlDbType.DateTime).Value = post.CreationDate; cmd.Parameters.Add("@text", SqlDbType.VarChar, 200).Value = post.Text; cmd.Parameters.Add("@title", SqlDbType.VarChar, 100).Value = post.Title; cmd.ExecuteNonQuery(); } } }
private void WaitUntilPostAdded(PostDetails post) { var repo = GetRepo(); Helpers.WaitUntil(() => repo.GetPosts().Any(x => x.Text == post.Text && x.Title == post.Title), MaxTimeoutSeconds); }
public void AddPost(PostDetails post) { client.AddPost(post.ToDto()); }