public List<Module> GetModulesByCompany(int companyid)
{
List<Module> lstModules = null;
Module module = null;
using (var conn = new SqlConnection(PrescienceRxConnectionString))
{
conn.Open();
using (var cmd = new SqlCommand(GetModulesByCompanyIdSp, conn))
{
cmd.CommandType = System.Data.CommandType.StoredProcedure;
cmd.Parameters.Add("@CompanyId", System.Data.SqlDbType.Int);
cmd.Parameters["@CompanyId"].Value = companyid;
using (var myReader = cmd.ExecuteReader())
{
try
{
if (myReader.HasRows)
{
lstModules = new List<Module>();
while (myReader.Read())
{
module = new Module(myReader);
lstModules.Add(module);
}
}
}
catch (Exception ex)
{
// TODO Logg Error here
}
}
}
}
return lstModules;
}