public int AddPost(Post post) { int id; try { using (SqlCommand command = new SqlCommand("AddPosts")) { command.CommandType = CommandType.StoredProcedure; command.Parameters.AddWithValue("@date", post.date); command.Parameters.AddWithValue("@title", post.title); command.Parameters.AddWithValue("@postPreviewContent", post.postPreviewContent); command.Parameters.AddWithValue("@postContent", post.postContent); command.Parameters.AddWithValue("@imgURL", post.imgURL); command.Parameters.AddWithValue("@numberOfComments", Convert.ToInt32(post.numberOfComments)); id = _baseDataAccess.Add(command); } //DataTable dataTable = new DataTable(); //PropertyInfo[] Props = typeof(Post).GetProperties(BindingFlags.Public | BindingFlags.Instance); //foreach (PropertyInfo prop in Props) //{ // dataTable.Columns.Add(prop.Name); //} //var values = new object[Props.Length]; //for (int i = 0; i < Props.Length; i++) //{ // values[i] = Props[i].GetValue(post, null); //} //dataTable.Rows.Add(values); } catch (Exception ex) { throw ex; } return(id); }