diff --git a/dotnet_3/cs/rest/Menu.API/Menu.API/Controllers/CategoriesController.cs b/dotnet_3/cs/rest/Menu.API/Menu.API/Controllers/CategoriesController.cs index 2a8c4dd4e..bc6dfb08a 100644 --- a/dotnet_3/cs/rest/Menu.API/Menu.API/Controllers/CategoriesController.cs +++ b/dotnet_3/cs/rest/Menu.API/Menu.API/Controllers/CategoriesController.cs @@ -35,7 +35,7 @@ public CategoryDto Get(Guid id) { } [HttpPost] - [Authorize(Roles = "Admin")] + // [Authorize(Roles = "Admin")] public async Task Post([FromBody] CategoryDto category) { try { var entity = _mapper.Map(category); @@ -51,7 +51,7 @@ public async Task Post([FromBody] CategoryDto category) { [HttpPut("{id}")] - [Authorize(Roles = "Admin")] + // [Authorize(Roles = "Admin")] public async Task Put(Guid id, [FromBody] CategoryDto categoryDto) { try { if (id != categoryDto.Id) @@ -67,7 +67,7 @@ public async Task Put(Guid id, [FromBody] CategoryDto categoryDto } [HttpDelete("{id}")] - [Authorize(Roles = "Admin")] + // [Authorize(Roles = "Admin")] public async Task Delete(Guid id) { try { var category = _repository.Get(id); diff --git a/dotnet_3/cs/rest/Menu.API/Menu.API/Controllers/FoodsController.cs b/dotnet_3/cs/rest/Menu.API/Menu.API/Controllers/FoodsController.cs index 3e341ca40..165525179 100644 --- a/dotnet_3/cs/rest/Menu.API/Menu.API/Controllers/FoodsController.cs +++ b/dotnet_3/cs/rest/Menu.API/Menu.API/Controllers/FoodsController.cs @@ -50,7 +50,7 @@ public FoodDto Get(Guid id) } [HttpPost] - [Authorize(Roles = "Admin")] + // [Authorize(Roles = "Admin")] public async Task Post([FromBody] FoodDto foodDto) { var food = _mapper.Map(foodDto); @@ -65,14 +65,14 @@ public async Task Post([FromBody] FoodDto foodDto) [HttpPost] [Route("UploadFoodImage")] - [Authorize(Roles = "Admin")] + // [Authorize(Roles = "Admin")] public Task Post([Bind] List files, [Bind] string foodId) { return _foodPictureService.UploadAndCreatePictures(files, foodId); } [HttpPut("{id}")] - [Authorize(Roles = "Admin")] + // [Authorize(Roles = "Admin")] [ProducesResponseType(304)] [ProducesResponseType(200)] [ProducesResponseType(400)] @@ -105,7 +105,7 @@ public async Task Put(Guid id, [FromBody] FoodDto foodDto) } [HttpDelete("{id}")] - [Authorize(Roles = "Admin")] + // [Authorize(Roles = "Admin")] public async Task Delete(Guid id) { var food = _repository.Get(id); diff --git a/dotnet_3/cs/rest/NCS/Controllers/NcsRestController.cs b/dotnet_3/cs/rest/NCS/Controllers/NcsRestController.cs index f3bc2a223..c1b060b68 100644 --- a/dotnet_3/cs/rest/NCS/Controllers/NcsRestController.cs +++ b/dotnet_3/cs/rest/NCS/Controllers/NcsRestController.cs @@ -1,4 +1,5 @@ using System; +using System.Globalization; using Microsoft.AspNetCore.Mvc; using NCS.Imp; @@ -12,7 +13,7 @@ public class NcsRestController : ControllerBase [Produces("application/json")] public IActionResult CheckTriangle(int a, int b, int c) { - var dto = new Dto {ResultAsInt = TriangleClassification.Classify(a, b, c)}; + var dto = new Dto {Result = TriangleClassification.Classify(a, b, c).ToString()}; return Ok(dto); } @@ -26,7 +27,7 @@ public IActionResult Bessj(int n, double x) return BadRequest(); } - var dto = new Dto {ResultAsDouble = new Bessj().BessjFunction(n, x)}; + var dto = new Dto {Result = new Bessj().BessjFunction(n, x).ToString(CultureInfo.InvariantCulture)}; return Ok(dto); } @@ -37,13 +38,13 @@ public IActionResult Expint(int n, double x) { try { - var dto = new Dto {ResultAsDouble = Imp.Expint.Exe(n, x)}; + var dto = new Dto {Result = Imp.Expint.Exe(n, x).ToString(CultureInfo.InvariantCulture)}; return Ok(dto); } catch (Exception e) { - return BadRequest(e); + return BadRequest(e.Message); } } @@ -58,13 +59,13 @@ public IActionResult Fisher(int m, int n, double x) try { - var dto = new Dto {ResultAsDouble = Imp.Fisher.Exe(m, n, x)}; + var dto = new Dto {Result = Imp.Fisher.Exe(m, n, x).ToString(CultureInfo.InvariantCulture)}; return Ok(dto); } catch (Exception e) { - return BadRequest(e); + return BadRequest(e.Message); } } @@ -78,13 +79,13 @@ public IActionResult Gammq(double a, double x) var gammq = new Gammq(); - dto.ResultAsDouble = gammq.Exe(a, x); + dto.Result = gammq.Exe(a, x).ToString(CultureInfo.InvariantCulture); return Ok(dto); } catch (Exception e) { - return BadRequest(e); + return BadRequest(e.Message); } } @@ -99,7 +100,7 @@ public IActionResult Remainder(int a, int b) return BadRequest(); } - var dto = new Dto {ResultAsInt = Imp.Remainder.Exe(a, b)}; + var dto = new Dto {Result = Imp.Remainder.Exe(a, b).ToString()}; return Ok(dto); } diff --git a/dotnet_3/cs/rest/NCS/Dto.cs b/dotnet_3/cs/rest/NCS/Dto.cs index de69b2b46..762d89729 100644 --- a/dotnet_3/cs/rest/NCS/Dto.cs +++ b/dotnet_3/cs/rest/NCS/Dto.cs @@ -2,8 +2,9 @@ namespace NCS { public class Dto { - public int? ResultAsInt { get; set; } - - public double? ResultAsDouble { get; set; } + // public int? ResultAsInt { get; set; } + // + // public double? ResultAsDouble { get; set; } + public string Result { get; set; } } } \ No newline at end of file diff --git a/dotnet_3/cs/rest/SCS/Imp/Calc.cs b/dotnet_3/cs/rest/SCS/Imp/Calc.cs index 99f2e8209..34343bb3e 100644 --- a/dotnet_3/cs/rest/SCS/Imp/Calc.cs +++ b/dotnet_3/cs/rest/SCS/Imp/Calc.cs @@ -8,22 +8,32 @@ public static string Subject(string op, double arg1 , double arg2 ) { op = op.ToLower(); - var result = op switch - { - "pi" => Math.PI, - "e" => Math.E, - "sqrt" => Math.Sqrt(arg1), - "log" => Math.Log(arg1), - "sine" => Math.Sin(arg1), - "cosine" => Math.Cos(arg1), - "tangent" => Math.Tan(arg1), - "plus" => arg1 + arg2, - "subtract" => arg1 - arg2, - "multiply" => arg1 * arg2, - "divide" => arg1 / arg2, - _ => 0.0 - }; - + double result; + if (op == "pi") + result = Math.PI; + else if (op == "e") + result = Math.E; + else if (op == "sqrt") + result = Math.Sqrt(arg1); + else if (op == "log") + result = Math.Log(arg1); + else if (op == "sine") + result = Math.Sin(arg1); + else if (op == "cosine") + result = Math.Cos(arg1); + else if (op == "tangent") + result = Math.Tan(arg1); + else if (op == "plus") + result = arg1 + arg2; + else if (op == "subtract") + result = arg1 - arg2; + else if (op == "multiply") + result = arg1 * arg2; + else if (op == "divide") + result = arg1 / arg2; + else + result = 0.0; + return "" + result; } } diff --git a/dotnet_3/cs/rest/SCS/Imp/Cookie.cs b/dotnet_3/cs/rest/SCS/Imp/Cookie.cs index 656849389..30967eb30 100644 --- a/dotnet_3/cs/rest/SCS/Imp/Cookie.cs +++ b/dotnet_3/cs/rest/SCS/Imp/Cookie.cs @@ -8,26 +8,21 @@ public static string Subject(string name, string val, string site) val = val.ToLower(); site = site.ToLower(); var result = 0; - - switch (name) - { - case "userid": - { - if (val.Length > 6) { - if ("user".Equals(val[..4])) { - result = 1; - } - } - break; + if (name == "userid") { + if (val.Length > 6) { + if ("user".Equals(val[..4])) { + result = 1; + } } - case "session" when "am".Equals(val) && "abc.com".Equals(site): - result = 1; - break; - case "session": - result = 2; - break; } + else if (name == "session" && ("am".Equals(val) && "abc.com".Equals(site))) { + result = 1; + } + else if (name == "session") { + result = 2; + } + return "" + result; } } diff --git a/dotnet_3/cs/rest/SCS/Imp/DateParse.cs b/dotnet_3/cs/rest/SCS/Imp/DateParse.cs index 0ca96b042..fbc34e2d4 100644 --- a/dotnet_3/cs/rest/SCS/Imp/DateParse.cs +++ b/dotnet_3/cs/rest/SCS/Imp/DateParse.cs @@ -20,45 +20,29 @@ public static string Subject(string dayName, string monthName) result = 1; } - switch (monthName) - { - case "jan": - result += 1; - break; - case "feb": - result += 2; - break; - case "mar": - result += 3; - break; - case "apr": - result += 4; - break; - case "may": - result += 5; - break; - case "jun": - result += 6; - break; - case "jul": - result += 7; - break; - case "aug": - result += 8; - break; - case "sep": - result += 9; - break; - case "oct": - result += 10; - break; - case "nov": - result += 11; - break; - case "dec": - result += 12; - break; - } + if (monthName == "jan") + result += 1; + else if (monthName == "feb") + result += 2; + else if (monthName == "mar") + result += 3; + else if (monthName == "apr") + result += 4; + else if (monthName == "may") + result += 5; + else if (monthName == "jun") + result += 6; + else if (monthName == "jul") + result += 7; + else if (monthName == "aug") + result += 8; + else if (monthName == "sep") + result += 9; + else if (monthName == "oct") + result += 10; + else if (monthName == "nov") + result += 11; + else if (monthName == "dec") result += 12; return "" + result; } diff --git a/dotnet_3/cs/rest/SCS/Imp/FileSuffix.cs b/dotnet_3/cs/rest/SCS/Imp/FileSuffix.cs index b7f1e8f5f..74a69950c 100644 --- a/dotnet_3/cs/rest/SCS/Imp/FileSuffix.cs +++ b/dotnet_3/cs/rest/SCS/Imp/FileSuffix.cs @@ -17,58 +17,34 @@ public static string Subject(string directory, string file) if (lastPart <= 0) return "" + result; var suffix = fileParts[lastPart]; - - switch (directory) - { - //Console.WriteLine("{0}, {1}", directory, suffix); - case "text": - { - if ("txt".Equals(suffix)) - { - result = 1; - } - break; + if (directory == "text") { + if ("txt".Equals(suffix)) { + result = 1; } - case "acrobat": - { - if ("pdf".Equals(suffix)) - { - //print("acrobat"); - result = 2; - } - - break; + } + else if (directory == "acrobat") { + if ("pdf".Equals(suffix)) { + //print("acrobat"); + result = 2; } - case "word": - { - if ("doc".Equals(suffix)) - { - //print("word"); - result = 3; - } - - break; + } + else if (directory == "word") { + if ("doc".Equals(suffix)) { + //print("word"); + result = 3; } - case "bin": - { - if ("exe".Equals(suffix)) - { - //print("bin"); - result = 4; - } - - break; + } + else if (directory == "bin") { + if ("exe".Equals(suffix)) { + //print("bin"); + result = 4; } - case "lib": - { - if ("dll".Equals(suffix)) - { - //print("lib"); - result = 5; - } - - break; + } + else if (directory == "lib") { + if ("dll".Equals(suffix)) { + //print("lib"); + result = 5; } } diff --git a/dotnet_3/cs/rest/SCS/Imp/Pat.cs b/dotnet_3/cs/rest/SCS/Imp/Pat.cs index e4abe748a..cb332cede 100644 --- a/dotnet_3/cs/rest/SCS/Imp/Pat.cs +++ b/dotnet_3/cs/rest/SCS/Imp/Pat.cs @@ -46,7 +46,7 @@ public static string Subject(string txt, string pat) int j; if (txt[i] == pat[0]) { - possMatch = txt.Substring(i, i + patLen); + possMatch = txt.Substring(i, patLen); if (possMatch.Equals(pat)) { //FOUND pat @@ -56,7 +56,8 @@ public static string Subject(string txt, string pat) { if (txt[j] == patRev[0]) { - possMatch = txt.Substring(j, j + patLen); + //possMatch = txt.Substring(j, j + patLen); + possMatch = txt.Substring(j, patLen); if (possMatch.Equals(patRev)) { if (j == i + patLen) @@ -74,7 +75,7 @@ public static string Subject(string txt, string pat) } else if (txt[i] == patRev[0]) { - possMatch = txt.Substring(i, i + patLen); + possMatch = txt.Substring(i, patLen); if (possMatch.Equals(patRev)) { //FOUND pat REVERSE @@ -84,7 +85,7 @@ public static string Subject(string txt, string pat) { if (txt[j] == pat[0]) { - possMatch = txt.Substring(j, j + patLen); + possMatch = txt.Substring(j, patLen); if (possMatch.Equals(pat)) { if (j == i + patLen) diff --git a/dotnet_3/cs/rest/SCS/Imp/Text2Txt.cs b/dotnet_3/cs/rest/SCS/Imp/Text2Txt.cs index 860cf9a9b..fa84aab6b 100644 --- a/dotnet_3/cs/rest/SCS/Imp/Text2Txt.cs +++ b/dotnet_3/cs/rest/SCS/Imp/Text2Txt.cs @@ -1,41 +1,26 @@ -namespace SCS.Imp -{ - public class Text2Txt - { - public static string Subject(string word1, string word2, string word3) - { +namespace SCS.Imp { + public class Text2Txt { + public static string Subject(string word1, string word2, string word3) { //CONVERT ENGLISH TEXT txt INTO MOBILE TELEPHONE TXT //BY SUBSTITUTING ABBREVIATIONS FOR COMMON WORDS word1 = word1.ToLower(); word2 = word2.ToLower(); word3 = word3.ToLower(); var result = ""; - - switch (word1) - { - case "two": - result = "2"; - break; - case "for": - case "four": - result = "4"; - break; - case "you": - result = "u"; - break; - case "and": - result = "n"; - break; - case "are": - result = "r"; - break; - case "see" when word2.Equals("you"): - result = "cu"; - break; - case "by" when word2.Equals("the") && word3.Equals("way"): - result = "btw"; - break; - } + + if (word1.Equals("two")) + result = "2"; + else if (word1.Equals("for") || word1.Equals("four")) + result = "4"; + else if (word1.Equals("you")) + result = "u"; + else if (word1.Equals("and")) + result = "n"; + else if (word1.Equals("are")) + result = "r"; + else if (word1.Equals("see") && word2.Equals("you")) + result = "cu"; + else if (word1.Equals("by") && (word2.Equals("the") && word3.Equals("way"))) result = "btw"; return result; } diff --git a/dotnet_3/cs/rest/SCS/Imp/Title.cs b/dotnet_3/cs/rest/SCS/Imp/Title.cs index 2b0948a11..a20d86a0a 100644 --- a/dotnet_3/cs/rest/SCS/Imp/Title.cs +++ b/dotnet_3/cs/rest/SCS/Imp/Title.cs @@ -9,49 +9,34 @@ public static string Subject(string sex, string title) title = title.ToLower(); var result = -1; - switch (sex) - { - case "male": - { - if ("mr".Equals(title) || - "dr".Equals(title) || - "sir".Equals(title) || - "rev".Equals(title) || - "rthon".Equals(title) || - "prof".Equals(title)) - { - result = 1; - } - - break; + if (sex == "male") { + if ("mr".Equals(title) || + "dr".Equals(title) || + "sir".Equals(title) || + "rev".Equals(title) || + "rthon".Equals(title) || + "prof".Equals(title)) { + result = 1; } - case "female": - { - if ("mrs".Equals(title) || - "miss".Equals(title) || - "ms".Equals(title) || - "dr".Equals(title) || - "lady".Equals(title) || - "rev".Equals(title) || - "rthon".Equals(title) || - "prof".Equals(title)) - { - result = 0; - } - - break; + } + else if (sex == "female") { + if ("mrs".Equals(title) || + "miss".Equals(title) || + "ms".Equals(title) || + "dr".Equals(title) || + "lady".Equals(title) || + "rev".Equals(title) || + "rthon".Equals(title) || + "prof".Equals(title)) { + result = 0; } - case "none": - { - if ("dr".Equals(title) || - "rev".Equals(title) || - "rthon".Equals(title) || - "prof".Equals(title)) - { - result = 2; - } - - break; + } + else if (sex == "none") { + if ("dr".Equals(title) || + "rev".Equals(title) || + "rthon".Equals(title) || + "prof".Equals(title)) { + result = 2; } } diff --git a/dotnet_3/em/embedded/rest/MenuAPIDriver/EmbeddedEvoMasterController.cs b/dotnet_3/em/embedded/rest/MenuAPIDriver/EmbeddedEvoMasterController.cs index d2df135f6..82356e034 100644 --- a/dotnet_3/em/embedded/rest/MenuAPIDriver/EmbeddedEvoMasterController.cs +++ b/dotnet_3/em/embedded/rest/MenuAPIDriver/EmbeddedEvoMasterController.cs @@ -27,10 +27,7 @@ private static void Main(string[] args) { if (args.Length > 1) { _sutPort = Int32.Parse(args[1]); - } else { - var ephemeralPort = embeddedEvoMasterController.GetEphemeralTcpPort(); - _sutPort = ephemeralPort; - } + } var instrumentedSutStarter = new InstrumentedSutStarter(embeddedEvoMasterController); @@ -38,6 +35,10 @@ private static void Main(string[] args) { instrumentedSutStarter.Start(); } + + public EmbeddedEvoMasterController(){ + _sutPort = GetEphemeralTcpPort(); + } public override string GetDatabaseDriverName() => null; diff --git a/dotnet_3/em/embedded/rest/NcsDriver/EmbeddedEvoMasterController.cs b/dotnet_3/em/embedded/rest/NcsDriver/EmbeddedEvoMasterController.cs index 8a843467a..b4faa8eb7 100644 --- a/dotnet_3/em/embedded/rest/NcsDriver/EmbeddedEvoMasterController.cs +++ b/dotnet_3/em/embedded/rest/NcsDriver/EmbeddedEvoMasterController.cs @@ -22,10 +22,7 @@ static void Main(string[] args) { if (args.Length > 1) { _sutPort = Int32.Parse(args[1]); - } else { - var ephemeralPort = embeddedEvoMasterController.GetEphemeralTcpPort(); - _sutPort = ephemeralPort; - } + } var instrumentedSutStarter = new InstrumentedSutStarter(embeddedEvoMasterController); @@ -34,6 +31,11 @@ static void Main(string[] args) { instrumentedSutStarter.Start(); } + + public EmbeddedEvoMasterController(){ + _sutPort = GetEphemeralTcpPort(); + } + public override string StartSut() { diff --git a/dotnet_3/em/embedded/rest/SampleProjectDriver/EmbeddedEvoMasterController.cs b/dotnet_3/em/embedded/rest/SampleProjectDriver/EmbeddedEvoMasterController.cs index 61ae9db52..b3ab6e2a4 100644 --- a/dotnet_3/em/embedded/rest/SampleProjectDriver/EmbeddedEvoMasterController.cs +++ b/dotnet_3/em/embedded/rest/SampleProjectDriver/EmbeddedEvoMasterController.cs @@ -32,10 +32,7 @@ static void Main(string[] args) { if (args.Length > 1) { _sutPort = Int32.Parse(args[1]); - } else { - var ephemeralPort = embeddedEvoMasterController.GetEphemeralTcpPort(); - _sutPort = ephemeralPort; - } + } var instrumentedSutStarter = new InstrumentedSutStarter(embeddedEvoMasterController); @@ -44,6 +41,10 @@ static void Main(string[] args) { instrumentedSutStarter.Start(); } + public EmbeddedEvoMasterController(){ + _sutPort = GetEphemeralTcpPort(); + } + public override string GetDatabaseDriverName() => null; public override List GetInfoForAuthentication() => null; diff --git a/dotnet_3/em/embedded/rest/ScsDriver/EmbeddedEvoMasterController.cs b/dotnet_3/em/embedded/rest/ScsDriver/EmbeddedEvoMasterController.cs index c4a3d6195..368347c44 100644 --- a/dotnet_3/em/embedded/rest/ScsDriver/EmbeddedEvoMasterController.cs +++ b/dotnet_3/em/embedded/rest/ScsDriver/EmbeddedEvoMasterController.cs @@ -21,10 +21,7 @@ static void Main(string[] args) { if (args.Length > 1) { _sutPort = Int32.Parse(args[1]); - } else { - var ephemeralPort = embeddedEvoMasterController.GetEphemeralTcpPort(); - _sutPort = ephemeralPort; - } + } var instrumentedSutStarter = new InstrumentedSutStarter(embeddedEvoMasterController); @@ -33,8 +30,12 @@ static void Main(string[] args) { instrumentedSutStarter.Start(); } + public EmbeddedEvoMasterController(){ + _sutPort = GetEphemeralTcpPort(); + } + public override string StartSut() { - + Task.Run(() => { SCS.Program.Main(new[] {_sutPort.ToString()}); }); WaitUntilSutIsRunning(_sutPort);