-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
114 lines (103 loc) · 3.24 KB
/
Program.cs
File metadata and controls
114 lines (103 loc) · 3.24 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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
using Microsoft.AspNetCore.Builder;
using System.Diagnostics.Metrics;
using System.Security.Cryptography;
var builder = WebApplication.CreateBuilder(args);
var app = builder.Build();
app.UseHttpsRedirection();
app.MapGet("/api/{breadType}/{weight}", (string breadType, int weight) =>
{
int mass = weight;
float waterPercent;
float yeastPercent;
float saltPercent;
float sugarPercent;
float fatPercent;
switch (breadType)
{
case "sandwich":
waterPercent = 63.0F;
yeastPercent = 1.2F;
saltPercent = 1.0F;
sugarPercent = 3.5F;
fatPercent = 8.0F;
break;
case "focaccia":
waterPercent = 90.0F;
yeastPercent = 0.75F;
saltPercent = 3.5F;
sugarPercent = 0.0F;
fatPercent = 9.4F;
break;
case "ciabatta":
waterPercent = 82.0F;
yeastPercent = 0.4F;
saltPercent = 2.2F;
sugarPercent = 0.0F;
fatPercent = 0.0F;
break;
case "french":
waterPercent = 66.0F;
yeastPercent = 1.25F;
saltPercent = 2.0F;
sugarPercent = 0.0F;
fatPercent = 0.0F;
break;
case "buns":
waterPercent = 66.0F;
yeastPercent = 2.0F;
saltPercent = 1.5F;
sugarPercent = 2.5F;
fatPercent = 5.0F;
break;
case "rolls":
waterPercent = 60.0F;
yeastPercent = 2.3F;
saltPercent = 1.3F;
sugarPercent = 10.0F;
fatPercent = 10.0F;
break;
case "dumplings":
waterPercent = 71.0F;
yeastPercent = 0.0F;
saltPercent = 1.0F;
sugarPercent = 0.0F;
fatPercent = 9.0F;
break;
case "pizza":
waterPercent = 59.0F;
yeastPercent = 1.25F;
saltPercent = 2.0F;
sugarPercent = 0.0F;
fatPercent = 0.0F;
break;
default:
waterPercent = 65.0F;
yeastPercent = 1.2F;
saltPercent = 2.0F;
sugarPercent = 2.0F;
fatPercent = 2.0F;
break;
}
float TotalPercent = 1.0f + (waterPercent + yeastPercent + saltPercent + sugarPercent + fatPercent) / 100;
float Flour = (mass / TotalPercent);
var bread = new Dough
(
(string)breadType,
(int)mass,
(int)Math.Ceiling(Flour),
(int)(Math.Ceiling(Flour * (waterPercent / 100))),
(int)(Math.Ceiling(Flour * (yeastPercent / 100))),
(int)(Math.Ceiling(Flour * (saltPercent / 100))),
(int)(Math.Ceiling(Flour * (sugarPercent / 100))),
(int)(Math.Ceiling(Flour * (fatPercent / 100)))
);
return (bread);
});
app.MapGet("/api", () =>
{
return("Instructions: After /api in URL add bread type and weight in grams, for example: /api/ciabatta/900 (other types: sandwich, focaccia, french, pizza, rolls, buns, or dumplings; weight is in grams)");
});
app.Run();
internal record Dough(string Type, int Grams, int Flour, int Water, int Yeast, int Salt, int Sugar, int Oil)
{
}