/
DAL Layer Structure.txt
59 lines (50 loc) · 1.47 KB
/
DAL Layer Structure.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// NOTE! internal mode - this 'DataBase' layer only accessible within the current assembly!
namespace DAL.DataBase
{
internal class Scooters
{
public static SqlDataReader Get(bool? IsAvailable, bool? IsActive)
{
try
{
SqlParameter[] prms = {
new SqlParameter("@IsAvailable", IsAvailable),
new SqlParameter("@IsActive", IsActive)
};
return SqlHelper.ExecuteReader(Config.Keys.ConnectionString, CommandType.StoredProcedure, "sp_Scooters_Get");
}
catch { return null; }
}
}
}
namespace DAL.Repository
{
public class Scooters
{
public static List<Scooter> Get()
{
var dr = DataBase.Scooters.Get(null, null);
return ScootersLoader.Load(dr);
}
public static List<Scooter> GetAvailable()
{
var dr = DataBase.Scooters.Get(true, true);
return ScootersLoader.Load(dr);
}
}
internal class ScootersLoader{
public static List<Scooter> Load(SqlDataReader dr) {
if (dr == null) return null;
var scooters = new List<Scooter>();
using (dr)
{
if (dr.HasRows)
{
while (dr.Read())
scooters.Add(new Scooter { });
}
}
return scooters;
}
}
}