Skip to content

Commit a222855

Browse files
authored
Merge pull request #31 from EMResearch/dotnet-fix-suts
Dotnet fix suts
2 parents 5acf7a1 + 6e563c6 commit a222855

15 files changed

Lines changed: 175 additions & 232 deletions

File tree

dotnet_3/cs/rest/Menu.API/Menu.API/Controllers/CategoriesController.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public CategoryDto Get(Guid id) {
3535
}
3636

3737
[HttpPost]
38-
[Authorize(Roles = "Admin")]
38+
// [Authorize(Roles = "Admin")]
3939
public async Task<IActionResult> Post([FromBody] CategoryDto category) {
4040
try {
4141
var entity = _mapper.Map<Category>(category);
@@ -51,7 +51,7 @@ public async Task<IActionResult> Post([FromBody] CategoryDto category) {
5151

5252

5353
[HttpPut("{id}")]
54-
[Authorize(Roles = "Admin")]
54+
// [Authorize(Roles = "Admin")]
5555
public async Task<IActionResult> Put(Guid id, [FromBody] CategoryDto categoryDto) {
5656
try {
5757
if (id != categoryDto.Id)
@@ -67,7 +67,7 @@ public async Task<IActionResult> Put(Guid id, [FromBody] CategoryDto categoryDto
6767
}
6868

6969
[HttpDelete("{id}")]
70-
[Authorize(Roles = "Admin")]
70+
// [Authorize(Roles = "Admin")]
7171
public async Task<IActionResult> Delete(Guid id) {
7272
try {
7373
var category = _repository.Get(id);

dotnet_3/cs/rest/Menu.API/Menu.API/Controllers/FoodsController.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public FoodDto Get(Guid id)
5050
}
5151

5252
[HttpPost]
53-
[Authorize(Roles = "Admin")]
53+
// [Authorize(Roles = "Admin")]
5454
public async Task<IActionResult> Post([FromBody] FoodDto foodDto)
5555
{
5656
var food = _mapper.Map<Food>(foodDto);
@@ -65,14 +65,14 @@ public async Task<IActionResult> Post([FromBody] FoodDto foodDto)
6565

6666
[HttpPost]
6767
[Route("UploadFoodImage")]
68-
[Authorize(Roles = "Admin")]
68+
// [Authorize(Roles = "Admin")]
6969
public Task Post([Bind] List<IFormFile> files, [Bind] string foodId)
7070
{
7171
return _foodPictureService.UploadAndCreatePictures(files, foodId);
7272
}
7373

7474
[HttpPut("{id}")]
75-
[Authorize(Roles = "Admin")]
75+
// [Authorize(Roles = "Admin")]
7676
[ProducesResponseType(304)]
7777
[ProducesResponseType(200)]
7878
[ProducesResponseType(400)]
@@ -105,7 +105,7 @@ public async Task<IActionResult> Put(Guid id, [FromBody] FoodDto foodDto)
105105
}
106106

107107
[HttpDelete("{id}")]
108-
[Authorize(Roles = "Admin")]
108+
// [Authorize(Roles = "Admin")]
109109
public async Task<IActionResult> Delete(Guid id)
110110
{
111111
var food = _repository.Get(id);

dotnet_3/cs/rest/NCS/Controllers/NcsRestController.cs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.Globalization;
23
using Microsoft.AspNetCore.Mvc;
34
using NCS.Imp;
45

@@ -12,7 +13,7 @@ public class NcsRestController : ControllerBase
1213
[Produces("application/json")]
1314
public IActionResult CheckTriangle(int a, int b, int c)
1415
{
15-
var dto = new Dto {ResultAsInt = TriangleClassification.Classify(a, b, c)};
16+
var dto = new Dto {Result = TriangleClassification.Classify(a, b, c).ToString()};
1617

1718
return Ok(dto);
1819
}
@@ -26,7 +27,7 @@ public IActionResult Bessj(int n, double x)
2627
return BadRequest();
2728
}
2829

29-
var dto = new Dto {ResultAsDouble = new Bessj().BessjFunction(n, x)};
30+
var dto = new Dto {Result = new Bessj().BessjFunction(n, x).ToString(CultureInfo.InvariantCulture)};
3031

3132
return Ok(dto);
3233
}
@@ -37,13 +38,13 @@ public IActionResult Expint(int n, double x)
3738
{
3839
try
3940
{
40-
var dto = new Dto {ResultAsDouble = Imp.Expint.Exe(n, x)};
41+
var dto = new Dto {Result = Imp.Expint.Exe(n, x).ToString(CultureInfo.InvariantCulture)};
4142

4243
return Ok(dto);
4344
}
4445
catch (Exception e)
4546
{
46-
return BadRequest(e);
47+
return BadRequest(e.Message);
4748
}
4849
}
4950

@@ -58,13 +59,13 @@ public IActionResult Fisher(int m, int n, double x)
5859

5960
try
6061
{
61-
var dto = new Dto {ResultAsDouble = Imp.Fisher.Exe(m, n, x)};
62+
var dto = new Dto {Result = Imp.Fisher.Exe(m, n, x).ToString(CultureInfo.InvariantCulture)};
6263

6364
return Ok(dto);
6465
}
6566
catch (Exception e)
6667
{
67-
return BadRequest(e);
68+
return BadRequest(e.Message);
6869
}
6970
}
7071

@@ -78,13 +79,13 @@ public IActionResult Gammq(double a, double x)
7879

7980
var gammq = new Gammq();
8081

81-
dto.ResultAsDouble = gammq.Exe(a, x);
82+
dto.Result = gammq.Exe(a, x).ToString(CultureInfo.InvariantCulture);
8283

8384
return Ok(dto);
8485
}
8586
catch (Exception e)
8687
{
87-
return BadRequest(e);
88+
return BadRequest(e.Message);
8889
}
8990
}
9091

@@ -99,7 +100,7 @@ public IActionResult Remainder(int a, int b)
99100
return BadRequest();
100101
}
101102

102-
var dto = new Dto {ResultAsInt = Imp.Remainder.Exe(a, b)};
103+
var dto = new Dto {Result = Imp.Remainder.Exe(a, b).ToString()};
103104

104105
return Ok(dto);
105106
}

dotnet_3/cs/rest/NCS/Dto.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ namespace NCS
22
{
33
public class Dto
44
{
5-
public int? ResultAsInt { get; set; }
6-
7-
public double? ResultAsDouble { get; set; }
5+
// public int? ResultAsInt { get; set; }
6+
//
7+
// public double? ResultAsDouble { get; set; }
8+
public string Result { get; set; }
89
}
910
}

dotnet_3/cs/rest/SCS/Imp/Calc.cs

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,32 @@ public static string Subject(string op, double arg1 , double arg2 )
88
{
99
op = op.ToLower();
1010

11-
var result = op switch
12-
{
13-
"pi" => Math.PI,
14-
"e" => Math.E,
15-
"sqrt" => Math.Sqrt(arg1),
16-
"log" => Math.Log(arg1),
17-
"sine" => Math.Sin(arg1),
18-
"cosine" => Math.Cos(arg1),
19-
"tangent" => Math.Tan(arg1),
20-
"plus" => arg1 + arg2,
21-
"subtract" => arg1 - arg2,
22-
"multiply" => arg1 * arg2,
23-
"divide" => arg1 / arg2,
24-
_ => 0.0
25-
};
26-
11+
double result;
12+
if (op == "pi")
13+
result = Math.PI;
14+
else if (op == "e")
15+
result = Math.E;
16+
else if (op == "sqrt")
17+
result = Math.Sqrt(arg1);
18+
else if (op == "log")
19+
result = Math.Log(arg1);
20+
else if (op == "sine")
21+
result = Math.Sin(arg1);
22+
else if (op == "cosine")
23+
result = Math.Cos(arg1);
24+
else if (op == "tangent")
25+
result = Math.Tan(arg1);
26+
else if (op == "plus")
27+
result = arg1 + arg2;
28+
else if (op == "subtract")
29+
result = arg1 - arg2;
30+
else if (op == "multiply")
31+
result = arg1 * arg2;
32+
else if (op == "divide")
33+
result = arg1 / arg2;
34+
else
35+
result = 0.0;
36+
2737
return "" + result;
2838
}
2939
}

dotnet_3/cs/rest/SCS/Imp/Cookie.cs

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,26 +8,21 @@ public static string Subject(string name, string val, string site)
88
val = val.ToLower();
99
site = site.ToLower();
1010
var result = 0;
11-
12-
switch (name)
13-
{
14-
case "userid":
15-
{
16-
if (val.Length > 6) {
17-
if ("user".Equals(val[..4])) {
18-
result = 1;
19-
}
20-
}
2111

22-
break;
12+
if (name == "userid") {
13+
if (val.Length > 6) {
14+
if ("user".Equals(val[..4])) {
15+
result = 1;
16+
}
2317
}
24-
case "session" when "am".Equals(val) && "abc.com".Equals(site):
25-
result = 1;
26-
break;
27-
case "session":
28-
result = 2;
29-
break;
3018
}
19+
else if (name == "session" && ("am".Equals(val) && "abc.com".Equals(site))) {
20+
result = 1;
21+
}
22+
else if (name == "session") {
23+
result = 2;
24+
}
25+
3126
return "" + result;
3227
}
3328
}

dotnet_3/cs/rest/SCS/Imp/DateParse.cs

Lines changed: 23 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -20,45 +20,29 @@ public static string Subject(string dayName, string monthName)
2020
result = 1;
2121
}
2222

23-
switch (monthName)
24-
{
25-
case "jan":
26-
result += 1;
27-
break;
28-
case "feb":
29-
result += 2;
30-
break;
31-
case "mar":
32-
result += 3;
33-
break;
34-
case "apr":
35-
result += 4;
36-
break;
37-
case "may":
38-
result += 5;
39-
break;
40-
case "jun":
41-
result += 6;
42-
break;
43-
case "jul":
44-
result += 7;
45-
break;
46-
case "aug":
47-
result += 8;
48-
break;
49-
case "sep":
50-
result += 9;
51-
break;
52-
case "oct":
53-
result += 10;
54-
break;
55-
case "nov":
56-
result += 11;
57-
break;
58-
case "dec":
59-
result += 12;
60-
break;
61-
}
23+
if (monthName == "jan")
24+
result += 1;
25+
else if (monthName == "feb")
26+
result += 2;
27+
else if (monthName == "mar")
28+
result += 3;
29+
else if (monthName == "apr")
30+
result += 4;
31+
else if (monthName == "may")
32+
result += 5;
33+
else if (monthName == "jun")
34+
result += 6;
35+
else if (monthName == "jul")
36+
result += 7;
37+
else if (monthName == "aug")
38+
result += 8;
39+
else if (monthName == "sep")
40+
result += 9;
41+
else if (monthName == "oct")
42+
result += 10;
43+
else if (monthName == "nov")
44+
result += 11;
45+
else if (monthName == "dec") result += 12;
6246

6347
return "" + result;
6448
}

dotnet_3/cs/rest/SCS/Imp/FileSuffix.cs

Lines changed: 23 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -17,58 +17,34 @@ public static string Subject(string directory, string file)
1717
if (lastPart <= 0) return "" + result;
1818

1919
var suffix = fileParts[lastPart];
20-
21-
switch (directory)
22-
{
23-
//Console.WriteLine("{0}, {1}", directory, suffix);
24-
case "text":
25-
{
26-
if ("txt".Equals(suffix))
27-
{
28-
result = 1;
29-
}
3020

31-
break;
21+
if (directory == "text") {
22+
if ("txt".Equals(suffix)) {
23+
result = 1;
3224
}
33-
case "acrobat":
34-
{
35-
if ("pdf".Equals(suffix))
36-
{
37-
//print("acrobat");
38-
result = 2;
39-
}
40-
41-
break;
25+
}
26+
else if (directory == "acrobat") {
27+
if ("pdf".Equals(suffix)) {
28+
//print("acrobat");
29+
result = 2;
4230
}
43-
case "word":
44-
{
45-
if ("doc".Equals(suffix))
46-
{
47-
//print("word");
48-
result = 3;
49-
}
50-
51-
break;
31+
}
32+
else if (directory == "word") {
33+
if ("doc".Equals(suffix)) {
34+
//print("word");
35+
result = 3;
5236
}
53-
case "bin":
54-
{
55-
if ("exe".Equals(suffix))
56-
{
57-
//print("bin");
58-
result = 4;
59-
}
60-
61-
break;
37+
}
38+
else if (directory == "bin") {
39+
if ("exe".Equals(suffix)) {
40+
//print("bin");
41+
result = 4;
6242
}
63-
case "lib":
64-
{
65-
if ("dll".Equals(suffix))
66-
{
67-
//print("lib");
68-
result = 5;
69-
}
70-
71-
break;
43+
}
44+
else if (directory == "lib") {
45+
if ("dll".Equals(suffix)) {
46+
//print("lib");
47+
result = 5;
7248
}
7349
}
7450

0 commit comments

Comments
 (0)