Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions WebApplicationLesson1/Controllers/CalculatorController1.cs
Original file line number Diff line number Diff line change
@@ -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 "Ошибка операции";
}
}
2 changes: 1 addition & 1 deletion WebApplicationLesson1/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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?}");
});
}
}
Expand Down