public IPackageType GetPackageType(string packageTypeName) { IPackageType result = null; using (var Conn = new SqlConnection(_connectionString)) { using (var Cmd = new SqlCommand($"SELECT PackageTypeID, PackageTypeName from Warehouse.PackageTypes where PackageTypeName = @PackageTypeName", Conn)) { Cmd.Parameters.Add("@PackageTypeName", SqlDbType.NVarChar); Cmd.Parameters["@PackageTypeName"].Value = packageTypeName; // Open SQL Connection Conn.Open(); // Execute SQL Command SqlDataReader rdr = Cmd.ExecuteReader(); // Loop through the results and add to list while (rdr.Read()) { result = new PackageType(); result.ID = rdr.GetInt32(0); result.PackageTypeName = rdr.GetString(1); } } } return(result); }
public PackageTypeBL() { packageTypeDAL = new PackageTypeRepository(); }