public List <GonderiResponse> KullaniciGonderileriGetir(string kulAdi) { List <GonderiResponse> lg = new List <GonderiResponse>(); using (SqlConnection conn = new SqlConnection(conStrig)) { conn.Open(); SqlCommand cmdd = new SqlCommand("spKullaniciGonderileriniGetir", conn); cmdd.Parameters.Add(new SqlParameter("@kullaniciAdi", kulAdi)); cmdd.CommandTimeout = 600; cmdd.CommandType = CommandType.StoredProcedure; SqlDataReader rd = cmdd.ExecuteReader(); if (rd.HasRows == true) { while (rd.Read()) { GonderiResponse g = new GonderiResponse(); g.baslik = rd["gonderiBaslik"].ToString(); g.icerik = rd["gonderiIcerik"].ToString(); g.tarih = rd["gonderiTarihi"].ToString(); g.begeni = (int)rd["begeniSayi"]; lg.Add(g); } } conn.Dispose(); conn.Close(); } return(lg); }
public GonderiResponse GonderiGetir(int gonderiId) { GonderiResponse g = new GonderiResponse(); using (SqlConnection conn = new SqlConnection(conStrig)) { conn.Open(); SqlCommand cmdd = new SqlCommand("spGonderiGetir", conn); cmdd.CommandType = CommandType.StoredProcedure; cmdd.Parameters.Add(new SqlParameter("@gonderiId", gonderiId)); cmdd.CommandTimeout = 600; cmdd.CommandType = CommandType.StoredProcedure; SqlDataReader rd = cmdd.ExecuteReader(); if (rd.HasRows == true) { while (rd.Read()) { g.baslik = rd["gonderiBaslik"].ToString(); g.icerik = rd["gonderiIcerik"].ToString(); g.tarih = rd["gonderiTarihi"].ToString(); g.kullaniciAdi = rd["kullaniciAdi"].ToString(); } } conn.Dispose(); conn.Close(); } return(g); }