How to encapsulate below codes (i need refoctoring)
public class mycollection
{
private DateTime tarih;
private int sira;
private int visitingcount;
public DateTime TARIH { get { return tarih; } set { tarih = value; } }
public int SIRA { get { return sira; } set { sira = value; } }
public int VISITINGCOUNT { get { return visitingcount; } set { visitingcount = value; } }
}
i used this class below
DataRow[] rows = dsChart.Tables[0].Select("TARIH>='" + DateGap1 + "' and TARIH<='" + DateGap2 + "'");
list = new List<mycollection>();
foreach (DataRow dr in rows)
{
mycollection mycol = new mycollection();
mycol.TARIH = Convert.ToDateTime(dr["TARIH"].ToString());
mycol.SIRA = Convert.ToInt32(dr["SIRA"].ToString());
mycol.VISITINGCOUNT = Convert.ToInt32(dr["VISITINGCOUNT"].ToString());
list.Add(mycol);
}
i need like that :
public static void LoadDepartman(string departmanName)
{
List<StuffDepartman> li = new List<StuffDepartman>();
GetDepartman departman = new GetDepartman();
DataSet ds = departman.GetDepartmanA(departmanName);
foreach (DataRow dr in ds.Tables[0].Rows)
{
li.Add(new StuffDepartman
{
Name = dr["Name"].ToString(),
SurName = dr["SurName"].ToString(),
Address = dr["Address"].ToString(),
Phone = dr["Phone"].ToString(),
DepartmanName = dr["DepartmanName"].ToString(),
Salary =int.Parse( dr["Salary"].ToString()),
Married = dr["Married"].ToString()
}
);
}
HttpContext.Current.Session["Stuffs"] = li;
}