-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#3 implement trig functions and add validations
- Loading branch information
BawinileM
committed
Jun 12, 2022
1 parent
829ce79
commit 30d8115
Showing
47 changed files
with
858 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
using Microsoft.AspNetCore.Mvc; | ||
using System; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using CalculatorAPI.Models; | ||
using CalculatorAPI.Repositories; | ||
|
||
|
||
namespace CalculatorAPI.Controllers | ||
{ | ||
public class TrigFunctionController | ||
{ | ||
[HttpPost("TrigFunctions")] | ||
public async Task<IActionResult> getInputs([FromBody] TrigPostRequest trig) | ||
{ | ||
|
||
TrigPostRequest d = new TrigPostRequest(); | ||
List<Trig> ls= trig.Tags; | ||
return new ObjectResult(TrigFunctionRepository.TrigImplement(ls)); | ||
|
||
} | ||
|
||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
namespace CalculatorAPI.Models | ||
{ | ||
public class Trig | ||
{ | ||
public string sign { get; set; } | ||
public string trigFunction { get; set; } | ||
public double degreeValue { get; set; } | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
namespace CalculatorAPI.Models | ||
{ | ||
public class TrigPostRequest | ||
{ | ||
|
||
public List<Trig>? Tags { get; set; } | ||
|
||
public TrigPostRequest(List<Trig> trig) | ||
{ | ||
Tags = trig; | ||
} | ||
|
||
public TrigPostRequest() | ||
{ | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
using Microsoft.AspNetCore.Mvc; | ||
using System; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using CalculatorAPI.Models; | ||
using CalculatorAPI.utils; | ||
|
||
namespace CalculatorAPI.Repositories | ||
{ | ||
public class TrigFunctionRepository | ||
{ public static double TrigImplement( List<Trig> ls){ | ||
Validations.Validate(ls); | ||
//assume the inputs are already validated: | ||
string answer = null; | ||
foreach (Trig obj in ls){ | ||
if(obj.trigFunction == "sin"){ | ||
answer = answer + obj.sign + Math.Round(Math.Sin(obj.degreeValue*Math.PI / 180.0), 2); | ||
} | ||
|
||
if(obj.trigFunction == "cos"){ | ||
answer = answer + obj.sign + Math.Round(Math.Cos(obj.degreeValue*Math.PI / 180.0), 2); | ||
} | ||
|
||
if(obj.trigFunction == "tan"){ | ||
answer = answer +obj.sign +Math.Round(Math.Tan(obj.degreeValue*Math.PI / 180.0), 2); | ||
} | ||
} | ||
return Eval(answer.Replace(",", ".")); | ||
|
||
} | ||
|
||
static Double Eval(String expression) | ||
{ | ||
System.Data.DataTable table = new System.Data.DataTable(); | ||
return Convert.ToDouble(table.Compute(expression, String.Empty)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
{ | ||
"runtimeTarget": { | ||
"name": ".NETCoreApp,Version=v6.0", | ||
"signature": "" | ||
}, | ||
"compilationOptions": {}, | ||
"targets": { | ||
".NETCoreApp,Version=v6.0": { | ||
"CalculatorAPI/1.0.0": { | ||
"dependencies": { | ||
"Swashbuckle.AspNetCore": "6.2.3" | ||
}, | ||
"runtime": { | ||
"CalculatorAPI.dll": {} | ||
} | ||
}, | ||
"Microsoft.Extensions.ApiDescription.Server/3.0.0": {}, | ||
"Microsoft.OpenApi/1.2.3": { | ||
"runtime": { | ||
"lib/netstandard2.0/Microsoft.OpenApi.dll": { | ||
"assemblyVersion": "1.2.3.0", | ||
"fileVersion": "1.2.3.0" | ||
} | ||
} | ||
}, | ||
"Swashbuckle.AspNetCore/6.2.3": { | ||
"dependencies": { | ||
"Microsoft.Extensions.ApiDescription.Server": "3.0.0", | ||
"Swashbuckle.AspNetCore.Swagger": "6.2.3", | ||
"Swashbuckle.AspNetCore.SwaggerGen": "6.2.3", | ||
"Swashbuckle.AspNetCore.SwaggerUI": "6.2.3" | ||
} | ||
}, | ||
"Swashbuckle.AspNetCore.Swagger/6.2.3": { | ||
"dependencies": { | ||
"Microsoft.OpenApi": "1.2.3" | ||
}, | ||
"runtime": { | ||
"lib/net6.0/Swashbuckle.AspNetCore.Swagger.dll": { | ||
"assemblyVersion": "6.2.3.0", | ||
"fileVersion": "6.2.3.0" | ||
} | ||
} | ||
}, | ||
"Swashbuckle.AspNetCore.SwaggerGen/6.2.3": { | ||
"dependencies": { | ||
"Swashbuckle.AspNetCore.Swagger": "6.2.3" | ||
}, | ||
"runtime": { | ||
"lib/net6.0/Swashbuckle.AspNetCore.SwaggerGen.dll": { | ||
"assemblyVersion": "6.2.3.0", | ||
"fileVersion": "6.2.3.0" | ||
} | ||
} | ||
}, | ||
"Swashbuckle.AspNetCore.SwaggerUI/6.2.3": { | ||
"runtime": { | ||
"lib/net6.0/Swashbuckle.AspNetCore.SwaggerUI.dll": { | ||
"assemblyVersion": "6.2.3.0", | ||
"fileVersion": "6.2.3.0" | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"libraries": { | ||
"CalculatorAPI/1.0.0": { | ||
"type": "project", | ||
"serviceable": false, | ||
"sha512": "" | ||
}, | ||
"Microsoft.Extensions.ApiDescription.Server/3.0.0": { | ||
"type": "package", | ||
"serviceable": true, | ||
"sha512": "sha512-LH4OE/76F6sOCslif7+Xh3fS/wUUrE5ryeXAMcoCnuwOQGT5Smw0p57IgDh/pHgHaGz/e+AmEQb7pRgb++wt0w==", | ||
"path": "microsoft.extensions.apidescription.server/3.0.0", | ||
"hashPath": "microsoft.extensions.apidescription.server.3.0.0.nupkg.sha512" | ||
}, | ||
"Microsoft.OpenApi/1.2.3": { | ||
"type": "package", | ||
"serviceable": true, | ||
"sha512": "sha512-Nug3rO+7Kl5/SBAadzSMAVgqDlfGjJZ0GenQrLywJ84XGKO0uRqkunz5Wyl0SDwcR71bAATXvSdbdzPrYRYKGw==", | ||
"path": "microsoft.openapi/1.2.3", | ||
"hashPath": "microsoft.openapi.1.2.3.nupkg.sha512" | ||
}, | ||
"Swashbuckle.AspNetCore/6.2.3": { | ||
"type": "package", | ||
"serviceable": true, | ||
"sha512": "sha512-cnzQDn0Le+hInsw2SYwlOhOCPXpYi/szcvnyqZJ12v+QyrLBwAmWXBg6RIyHB18s/mLeywC+Rg2O9ndz0IUNYQ==", | ||
"path": "swashbuckle.aspnetcore/6.2.3", | ||
"hashPath": "swashbuckle.aspnetcore.6.2.3.nupkg.sha512" | ||
}, | ||
"Swashbuckle.AspNetCore.Swagger/6.2.3": { | ||
"type": "package", | ||
"serviceable": true, | ||
"sha512": "sha512-qOF7j1sL0bWm8g/qqHVPCvkO3JlVvUIB8WfC98kSh6BT5y5DAnBNctfac7XR5EZf+eD7/WasvANncTqwZYfmWQ==", | ||
"path": "swashbuckle.aspnetcore.swagger/6.2.3", | ||
"hashPath": "swashbuckle.aspnetcore.swagger.6.2.3.nupkg.sha512" | ||
}, | ||
"Swashbuckle.AspNetCore.SwaggerGen/6.2.3": { | ||
"type": "package", | ||
"serviceable": true, | ||
"sha512": "sha512-+Xq7WdMCCfcXlnbLJVFNgY8ITdP2TRYIlpbt6IKzDw5FwFxdi9lBfNDtcT+/wkKwX70iBBFmXldnnd02/VO72A==", | ||
"path": "swashbuckle.aspnetcore.swaggergen/6.2.3", | ||
"hashPath": "swashbuckle.aspnetcore.swaggergen.6.2.3.nupkg.sha512" | ||
}, | ||
"Swashbuckle.AspNetCore.SwaggerUI/6.2.3": { | ||
"type": "package", | ||
"serviceable": true, | ||
"sha512": "sha512-bCRI87uKJVb4G+KURWm8LQrL64St04dEFZcF6gIM67Zc0Sr/N47EO83ybLMYOvfNdO1DCv8xwPcrz9J/VEhQ5g==", | ||
"path": "swashbuckle.aspnetcore.swaggerui/6.2.3", | ||
"hashPath": "swashbuckle.aspnetcore.swaggerui.6.2.3.nupkg.sha512" | ||
} | ||
} | ||
} |
Binary file not shown.
Binary file not shown.
Binary file not shown.
19 changes: 19 additions & 0 deletions
19
CalculatorAPI/bin/Debug/net6.0/CalculatorAPI.runtimeconfig.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"runtimeOptions": { | ||
"tfm": "net6.0", | ||
"frameworks": [ | ||
{ | ||
"name": "Microsoft.NETCore.App", | ||
"version": "6.0.0" | ||
}, | ||
{ | ||
"name": "Microsoft.AspNetCore.App", | ||
"version": "6.0.0" | ||
} | ||
], | ||
"configProperties": { | ||
"System.GC.Server": true, | ||
"System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization": false | ||
} | ||
} | ||
} |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"Logging": { | ||
"LogLevel": { | ||
"Default": "Information", | ||
"Microsoft.AspNetCore": "Warning" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"Logging": { | ||
"LogLevel": { | ||
"Default": "Information", | ||
"Microsoft.AspNetCore": "Warning" | ||
} | ||
}, | ||
"AllowedHosts": "*" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
{ | ||
"format": 1, | ||
"restore": { | ||
"C:\\Users\\mqweb001\\Desktop\\Design Patterns\\new_calculator\\Calculator\\CalculatorAPI\\CalculatorAPI.csproj": {} | ||
}, | ||
"projects": { | ||
"C:\\Users\\mqweb001\\Desktop\\Design Patterns\\new_calculator\\Calculator\\CalculatorAPI\\CalculatorAPI.csproj": { | ||
"version": "1.0.0", | ||
"restore": { | ||
"projectUniqueName": "C:\\Users\\mqweb001\\Desktop\\Design Patterns\\new_calculator\\Calculator\\CalculatorAPI\\CalculatorAPI.csproj", | ||
"projectName": "CalculatorAPI", | ||
"projectPath": "C:\\Users\\mqweb001\\Desktop\\Design Patterns\\new_calculator\\Calculator\\CalculatorAPI\\CalculatorAPI.csproj", | ||
"packagesPath": "C:\\Users\\mqweb001\\.nuget\\packages\\", | ||
"outputPath": "C:\\Users\\mqweb001\\Desktop\\Design Patterns\\new_calculator\\Calculator\\CalculatorAPI\\obj\\", | ||
"projectStyle": "PackageReference", | ||
"configFilePaths": [ | ||
"C:\\Users\\mqweb001\\AppData\\Roaming\\NuGet\\NuGet.Config", | ||
"C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.Offline.config" | ||
], | ||
"originalTargetFrameworks": [ | ||
"net6.0" | ||
], | ||
"sources": { | ||
"C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {}, | ||
"https://api.nuget.org/v3/index.json": {} | ||
}, | ||
"frameworks": { | ||
"net6.0": { | ||
"targetAlias": "net6.0", | ||
"projectReferences": {} | ||
} | ||
}, | ||
"warningProperties": { | ||
"warnAsError": [ | ||
"NU1605" | ||
] | ||
} | ||
}, | ||
"frameworks": { | ||
"net6.0": { | ||
"targetAlias": "net6.0", | ||
"dependencies": { | ||
"Swashbuckle.AspNetCore": { | ||
"target": "Package", | ||
"version": "[6.2.3, )" | ||
} | ||
}, | ||
"imports": [ | ||
"net461", | ||
"net462", | ||
"net47", | ||
"net471", | ||
"net472", | ||
"net48" | ||
], | ||
"assetTargetFallback": true, | ||
"warn": true, | ||
"frameworkReferences": { | ||
"Microsoft.AspNetCore.App": { | ||
"privateAssets": "none" | ||
}, | ||
"Microsoft.NETCore.App": { | ||
"privateAssets": "all" | ||
} | ||
}, | ||
"runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\6.0.201\\RuntimeIdentifierGraph.json" | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?xml version="1.0" encoding="utf-8" standalone="no"?> | ||
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<PropertyGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' "> | ||
<RestoreSuccess Condition=" '$(RestoreSuccess)' == '' ">True</RestoreSuccess> | ||
<RestoreTool Condition=" '$(RestoreTool)' == '' ">NuGet</RestoreTool> | ||
<ProjectAssetsFile Condition=" '$(ProjectAssetsFile)' == '' ">$(MSBuildThisFileDirectory)project.assets.json</ProjectAssetsFile> | ||
<NuGetPackageRoot Condition=" '$(NuGetPackageRoot)' == '' ">$(UserProfile)\.nuget\packages\</NuGetPackageRoot> | ||
<NuGetPackageFolders Condition=" '$(NuGetPackageFolders)' == '' ">C:\Users\mqweb001\.nuget\packages\</NuGetPackageFolders> | ||
<NuGetProjectStyle Condition=" '$(NuGetProjectStyle)' == '' ">PackageReference</NuGetProjectStyle> | ||
<NuGetToolVersion Condition=" '$(NuGetToolVersion)' == '' ">6.1.0</NuGetToolVersion> | ||
</PropertyGroup> | ||
<ItemGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' "> | ||
<SourceRoot Include="C:\Users\mqweb001\.nuget\packages\" /> | ||
</ItemGroup> | ||
<ImportGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' "> | ||
<Import Project="$(NuGetPackageRoot)microsoft.extensions.apidescription.server\3.0.0\build\Microsoft.Extensions.ApiDescription.Server.props" Condition="Exists('$(NuGetPackageRoot)microsoft.extensions.apidescription.server\3.0.0\build\Microsoft.Extensions.ApiDescription.Server.props')" /> | ||
<Import Project="$(NuGetPackageRoot)swashbuckle.aspnetcore\6.2.3\build\Swashbuckle.AspNetCore.props" Condition="Exists('$(NuGetPackageRoot)swashbuckle.aspnetcore\6.2.3\build\Swashbuckle.AspNetCore.props')" /> | ||
</ImportGroup> | ||
<PropertyGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' "> | ||
<PkgMicrosoft_Extensions_ApiDescription_Server Condition=" '$(PkgMicrosoft_Extensions_ApiDescription_Server)' == '' ">C:\Users\mqweb001\.nuget\packages\microsoft.extensions.apidescription.server\3.0.0</PkgMicrosoft_Extensions_ApiDescription_Server> | ||
</PropertyGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="utf-8" standalone="no"?> | ||
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<ImportGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' "> | ||
<Import Project="$(NuGetPackageRoot)microsoft.extensions.apidescription.server\3.0.0\build\Microsoft.Extensions.ApiDescription.Server.targets" Condition="Exists('$(NuGetPackageRoot)microsoft.extensions.apidescription.server\3.0.0\build\Microsoft.Extensions.ApiDescription.Server.targets')" /> | ||
</ImportGroup> | ||
</Project> |
4 changes: 4 additions & 0 deletions
4
CalculatorAPI/obj/Debug/net6.0/.NETCoreApp,Version=v6.0.AssemblyAttributes.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// <autogenerated /> | ||
using System; | ||
using System.Reflection; | ||
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v6.0", FrameworkDisplayName = "")] |
23 changes: 23 additions & 0 deletions
23
CalculatorAPI/obj/Debug/net6.0/CalculatorAPI.AssemblyInfo.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
//------------------------------------------------------------------------------ | ||
// <auto-generated> | ||
// This code was generated by a tool. | ||
// Runtime Version:4.0.30319.42000 | ||
// | ||
// Changes to this file may cause incorrect behavior and will be lost if | ||
// the code is regenerated. | ||
// </auto-generated> | ||
//------------------------------------------------------------------------------ | ||
|
||
using System; | ||
using System.Reflection; | ||
|
||
[assembly: System.Reflection.AssemblyCompanyAttribute("CalculatorAPI")] | ||
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")] | ||
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] | ||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")] | ||
[assembly: System.Reflection.AssemblyProductAttribute("CalculatorAPI")] | ||
[assembly: System.Reflection.AssemblyTitleAttribute("CalculatorAPI")] | ||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] | ||
|
||
// Generated by the MSBuild WriteCodeFragment class. | ||
|
1 change: 1 addition & 0 deletions
1
CalculatorAPI/obj/Debug/net6.0/CalculatorAPI.AssemblyInfoInputs.cache
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
3f63b985631337e8a6b733c2e03709a76a9a7dab |
Oops, something went wrong.