diff --git a/WebApplicationLesson1/Controllers/CalculatorController1.cs b/WebApplicationLesson1/Controllers/CalculatorController1.cs new file mode 100644 index 0000000..4a19605 --- /dev/null +++ b/WebApplicationLesson1/Controllers/CalculatorController1.cs @@ -0,0 +1,21 @@ +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; + +namespace WebApplication1.Controllers +{ + public class CalculatorController : Controller + { + public string Index(int a, int b, string c ) + { + + if(c== "+") + return $"{a} + {b} = {a + b}"; + + if(c=="-") + return $"{a} - {b} = {a - b}"; + if(c == "*") + return $"{a} * {b} = {a * b}"; + + return "Ошибка операции"; + } +} diff --git a/WebApplicationLesson1/Startup.cs b/WebApplicationLesson1/Startup.cs index d9a1eb0..007d4b6 100644 --- a/WebApplicationLesson1/Startup.cs +++ b/WebApplicationLesson1/Startup.cs @@ -46,7 +46,7 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { endpoints.MapControllerRoute( name: "default", - pattern: "{controller=Home}/{action=Index}/{id?}"); + pattern: "{controller=Home}/{action=Index}/{a?}/{b?}/{c?}"); }); } }