-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPBQuery.cs
More file actions
79 lines (63 loc) · 2.05 KB
/
Copy pathPBQuery.cs
File metadata and controls
79 lines (63 loc) · 2.05 KB
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
using System.Text;
namespace PixelBrewApi;
public static class PBQuery
{
public static string BuildGrinderQuery(Equipment equip)
{
StringBuilder sql = new StringBuilder();
sql.Append("UPDATE Equipment SET");
if (equip.Manufacturer != null && equip.Manufacturer.Length > 0)
{
sql.Append(" GrinderManufacturer = @GrinderManufacturer");
}
if (equip.Type != null && equip.Type.Length > 0)
{
sql.Append(", GrinderType = @GrinderType");
}
if (equip.Model != null && equip.Model.Length > 0)
{
sql.Append(", GrinderModel = @GrinderModel");
}
if (equip.Setting != null && equip.Setting.Length > 0)
{
sql.Append(", GrinderSetting = @GrinderSetting");
}
sql.Append(" WHERE GrinderId = @GrinderId");
return sql.ToString();
}
public static string BuildCoffeeQuery(Coffee cofe)
{
StringBuilder sql = new StringBuilder();
sql.Append("UPDATE Coffee SET");
if (cofe.CoffeeName != null && cofe.CoffeeName.Length > 0)
{
sql.Append(" CoffeeName = @CoffeeName");
}
if (cofe.Region != null && cofe.Region.Length > 0)
{
sql.Append(", Region = @Region");
}
if (cofe.Processing != null && cofe.Processing.Length > 0)
{
sql.Append(", Processing = @Processing");
}
if (cofe.Varietal != null && cofe.Varietal.Length > 0)
{
sql.Append(", Varietal = @Varietal");
}
if (cofe.RoastType != null && cofe.RoastType.Length > 0)
{
sql.Append(", RoastType = @RoastType");
}
if (cofe.Weight != null && cofe.Weight.Length > 0)
{
sql.Append(", Weight = @Weight");
}
if (cofe.RoastDate != null && cofe.RoastDate.Length > 0)
{
sql.Append(", RoastDate = @RoastDate");
}
sql.Append(" WHERE CoffeeId = @CoffeeId");
return sql.ToString();
}
}