public override List <Person> GetList(int StudentId) { List <Person> nextOfKins = new List <Person>(); DataTable dt = dbc.GetDataTable("SELECT * FROM vw_StudentNextOfKin WHERE StudentId=" + StudentId); dbc.CloseConnection(); foreach (DataRow dr in dt.Rows) { Person nextOfKin = new NextOfKin { StudentNextOfKinId = (int)dr["StudentNextOfKinId"], PersonId = (int)dr["NextOfKinId"], Phone = dr["Phone"].ToString(), MobilePhone = dr["MobilePhone"].ToString(), Relationship = dr["Relationship"].ToString(), FullName = dr["FullName"].ToString(), Addr1 = dr["Addr1"].ToString(), Addr2 = dr["Addr2"].ToString(), Addr3 = dr["Addr3"].ToString(), Addr4 = dr["Addr4"].ToString(), Postcode = dr["Postcode"].ToString(), Email = dr["Email"].ToString() }; //var nextOfKin = new NextOfKin(); // //if (nextOfKin.FullAddress == string.Empty) //{ nextOfKin.FullAddress = nextOfKin.GetFullAddress(); //} nextOfKins.Add(nextOfKin); } return(nextOfKins); }
public override List <Person> GetList() { //throw new NotImplementedException("not implemented"); List <Person> nextOfKinList = new List <Person>(); DataTable dt = dbc.GetDataTable("SELECT * FROM vw_NextOfKin"); foreach (DataRow dr in dt.Rows) { try { Person nextOfKin = new NextOfKin { //StudentNextOfKinId = (int)dr["StudentNextOfKinId"], PersonId = (int)dr["NextOfKinId"], FullName = dr["FullName"].ToString(), Addr1 = dr["Addr1"].ToString(), Addr2 = dr["Addr2"].ToString(), Addr3 = dr["Addr3"].ToString(), Addr4 = dr["Addr4"].ToString(), Postcode = dr["Postcode"].ToString(), Phone = dr["Phone"].ToString(), MobilePhone = dr["MobilePhone"].ToString(), Email = dr["Email"].ToString() }; nextOfKin.FullAddress = nextOfKin.GetFullAddress(); nextOfKinList.Add(nextOfKin); } catch (Exception ex) { throw new Exception(ex.Message); } } return(nextOfKinList); }