[WebMethod]
public
static
List<Customer> GetNameUserName(
int
id)
{
string
constr = ConfigurationManager.ConnectionStrings[
"DB"
].ConnectionString;
using
(SqlConnection con =
new
SqlConnection(constr))
{
using
(SqlCommand cmd =
new
SqlCommand(
"GetUserPOSTMODAL"
))
{
cmd.Connection = con;
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue(
"@ID"
, id);
List<Customer> customers =
new
List<Customer>();
con.Open();
SqlDataReader sdr = cmd.ExecuteReader();
while
(sdr.Read())
{
customers.Add(
new
Customer { Id = sdr[
"Id"
].ToString(), Name = sdr[
"Name"
].ToString(), UserName = sdr[
"UserName"
].ToString(), SendDate = sdr[
"SendDate"
].ToString(), ContentPost = sdr[
"ContentPost"
].ToString() });
}
con.Close();
return
customers;
}
}
}
[WebMethod]
public
static
string
InsertCommenttype(
string
username,
string
name,
string
contentpost,
string
Id,
string
senddate,
string
comments)
{
string
constr = ConfigurationManager.ConnectionStrings[
"DB"
].ConnectionString;
using
(SqlConnection con =
new
SqlConnection(constr))
{
using
(SqlCommand cmd =
new
SqlCommand(
"INSERT INTO Customers(UserName,Name,ContentPost,ID,Comments) VALUES(@UserName,@Name,@ContentPost,@ID,@Comments)"
))
{
cmd.Connection = con;
cmd.CommandType = CommandType.Text;
cmd.Parameters.AddWithValue(
"@UserName"
, HttpContext.Current.Session[
"userName"
].ToString());
cmd.Parameters.AddWithValue(
"@Name"
, name);
cmd.Parameters.AddWithValue(
"@ContentPost"
, contentpost);
cmd.Parameters.AddWithValue(
"@ID"
, Id);
cmd.Parameters.AddWithValue(
"@Comments"
, comments);
con.Open();
cmd.ExecuteNonQuery();
con.Close();
}
}
return
"Saved"
;
}
public
class
Customer
{
public
string
FriendUserName {
get
;
set
; }
public
string
ShareContent {
get
;
set
; }
public
string
ShareTodayDate {
get
;
set
; }
public
string
Comments {
get
;
set
; }
public
string
SharePostDate {
get
;
set
; }
public
string
UserName {
get
;
set
; }
public
string
ContentPost {
get
;
set
; }
public
string
Name {
get
;
set
; }
public
string
fName {
get
;
set
; }
public
string
Image {
get
;
set
; }
public
string
Image2 {
get
;
set
; }
public
string
SendDate {
get
;
set
; }
public
string
Id {
get
;
set
; }
}
}