From 80b988716d6ce2ac2873f77a9ba14e31b1a3edd0 Mon Sep 17 00:00:00 2001 From: Ivanov Stas Date: Mon, 2 Mar 2026 22:54:24 +0300 Subject: [PATCH 1/5] =?UTF-8?q?1=20=D0=97=D0=B0=D0=B4=D0=B0=D0=BD=D0=B8?= =?UTF-8?q?=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/StartController.cs | 32 +++++++++++++++++++ WebApplicationStart/Views/Home/Index.cshtml | 2 +- 2 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 WebApplicationStart/Controllers/StartController.cs diff --git a/WebApplicationStart/Controllers/StartController.cs b/WebApplicationStart/Controllers/StartController.cs new file mode 100644 index 0000000..5482aaa --- /dev/null +++ b/WebApplicationStart/Controllers/StartController.cs @@ -0,0 +1,32 @@ +using Microsoft.AspNetCore.Mvc; +using System.Diagnostics; +using WebApplicationStart.Models; + +namespace WebApplicationStart.Controllers +{ + public class StartController : Controller + { + private readonly ILogger _logger; + + public StartController(ILogger logger) + { + _logger = logger; + } + public string Hello() + { + if (DateTime.Now.Hour >= 0 && DateTime.Now.Hour < 6) + return "Доброй ночи"; + if (DateTime.Now.Hour >= 6 && DateTime.Now.Hour < 12) + return "Доброе утро"; + if (DateTime.Now.Hour >= 12 && DateTime.Now.Hour < 18) + return "Добрый день"; + return "Добрый вечер"; + } + + [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] + public IActionResult Error() + { + return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier }); + } + } +} \ No newline at end of file diff --git a/WebApplicationStart/Views/Home/Index.cshtml b/WebApplicationStart/Views/Home/Index.cshtml index 28d6e5f..cef89d4 100644 --- a/WebApplicationStart/Views/Home/Index.cshtml +++ b/WebApplicationStart/Views/Home/Index.cshtml @@ -3,7 +3,7 @@ }
-

Тут надо написать свою Фамилию и Имя

+

Иванов Станислав

Я учу ASP и это мой первый крутой проект.

From 6b40548f202f75e9898ee5dce4451e1a76762ea0 Mon Sep 17 00:00:00 2001 From: Ivanov Stas Date: Mon, 2 Mar 2026 23:01:47 +0300 Subject: [PATCH 2/5] =?UTF-8?q?=D0=B8=D0=B2=D0=B0=D0=BD=D0=BE=D0=B2=202=20?= =?UTF-8?q?=D0=B7=D0=B0=D0=B4=D0=B0=D0=BD=D0=B8=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/CalculatorController.cs | 26 +++++++++++++++++++ WebApplicationStart/Program.cs | 2 +- 2 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 WebApplicationStart/Controllers/CalculatorController.cs diff --git a/WebApplicationStart/Controllers/CalculatorController.cs b/WebApplicationStart/Controllers/CalculatorController.cs new file mode 100644 index 0000000..c441d5d --- /dev/null +++ b/WebApplicationStart/Controllers/CalculatorController.cs @@ -0,0 +1,26 @@ +using Microsoft.AspNetCore.Mvc; +using System.Diagnostics; +using WebApplicationStart.Models; + +namespace WebApplicationStart.Controllers +{ + public class CalculatorController : Controller + { + private readonly ILogger _logger; + + public CalculatorController(ILogger logger) + { + _logger = logger; + } + public string Index(int first, int second) + { + return $"{first} + {second} = {first + second}"; + } + + [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] + public IActionResult Error() + { + return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier }); + } + } +} \ No newline at end of file diff --git a/WebApplicationStart/Program.cs b/WebApplicationStart/Program.cs index 3155fc3..e54ac29 100644 --- a/WebApplicationStart/Program.cs +++ b/WebApplicationStart/Program.cs @@ -18,6 +18,6 @@ app.MapControllerRoute( name: "default", - pattern: "{controller=Home}/{action=Index}/{id?}"); + pattern: "{controller=Home}/{action=Index}/{first?}/{second?}"); app.Run(); From 5d184c14ffd5bce2b9a3c66e657d76d1d562d7e1 Mon Sep 17 00:00:00 2001 From: Ivanov Stas Date: Mon, 2 Mar 2026 23:20:16 +0300 Subject: [PATCH 3/5] =?UTF-8?q?3=D0=B7=D0=B0=D0=B4=D0=B0=D0=BD=D0=B8=D0=B5?= =?UTF-8?q?=20=D0=B2=D1=8B=D0=BF=D0=BE=D0=BB=D0=BD=D0=B8=D0=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/CalculatorController.cs | 10 ++++++++-- WebApplicationStart/Program.cs | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/WebApplicationStart/Controllers/CalculatorController.cs b/WebApplicationStart/Controllers/CalculatorController.cs index c441d5d..5186c4f 100644 --- a/WebApplicationStart/Controllers/CalculatorController.cs +++ b/WebApplicationStart/Controllers/CalculatorController.cs @@ -12,9 +12,15 @@ public CalculatorController(ILogger logger) { _logger = logger; } - public string Index(int first, int second) + public string Index(int first, int second,string sign) { - return $"{first} + {second} = {first + second}"; + switch (sign) + { + case "+": return $"{first} + {second} = {first + second}"; + case "-": return $"{first} - {second} = {first - second}"; + case "*": return $"{first} * {second} = {first * second}"; + default:return "неверный знак, попробуйте снова"; + } } [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] diff --git a/WebApplicationStart/Program.cs b/WebApplicationStart/Program.cs index e54ac29..2fe731f 100644 --- a/WebApplicationStart/Program.cs +++ b/WebApplicationStart/Program.cs @@ -18,6 +18,6 @@ app.MapControllerRoute( name: "default", - pattern: "{controller=Home}/{action=Index}/{first?}/{second?}"); + pattern: "{controller=Home}/{action=Index}/{first?}/{second?}/{sign=+}"); app.Run(); From 07d52a1254d61cface15fd6d0bfcc631f23fb58d Mon Sep 17 00:00:00 2001 From: Ivanov Stas Date: Tue, 3 Mar 2026 00:01:16 +0300 Subject: [PATCH 4/5] =?UTF-8?q?=D0=B8=D0=B2=D0=B0=D0=BD=D0=BE=D0=B2=204=20?= =?UTF-8?q?=D0=B7=D0=B0=D0=B4=D0=B0=D0=BD=D0=B8=D0=B5=20=D0=B2=D1=8B=D0=BF?= =?UTF-8?q?=D0=BE=D0=BB=D0=BD=D0=B8=D0=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/CalcController.cs | 35 +++++++++++++++++++ .../Controllers/CalculatorController.cs | 4 +-- WebApplicationStart/Program.cs | 2 +- 3 files changed, 38 insertions(+), 3 deletions(-) create mode 100644 WebApplicationStart/Controllers/CalcController.cs diff --git a/WebApplicationStart/Controllers/CalcController.cs b/WebApplicationStart/Controllers/CalcController.cs new file mode 100644 index 0000000..1a35289 --- /dev/null +++ b/WebApplicationStart/Controllers/CalcController.cs @@ -0,0 +1,35 @@ +using Microsoft.AspNetCore.Mvc; +using System.Diagnostics; +using WebApplicationStart.Models; + +namespace WebApplicationStart.Controllers +{ + public class CalcController : Controller + { + private readonly ILogger _logger; + + public CalcController(ILogger logger) + { + _logger = logger; + } + public string Index(double a = 0, double b = 0, string c = "+") + { + if (b == 0 && c == "/") + return "На ноль делить нельзя!"; + switch (c) + { + case "+": return $"{a} + {b} = {a + b}"; + case "-": return $"{a} - {b} = {a - b}"; + case "*": return $"{a} * {b} = {a * b}"; + case "/": return $"{a} / {b} = {a / b}"; + default: return "неверный знак, попробуйте снова"; + } + } + + [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] + public IActionResult Error() + { + return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier }); + } + } +} \ No newline at end of file diff --git a/WebApplicationStart/Controllers/CalculatorController.cs b/WebApplicationStart/Controllers/CalculatorController.cs index 5186c4f..3f49e2a 100644 --- a/WebApplicationStart/Controllers/CalculatorController.cs +++ b/WebApplicationStart/Controllers/CalculatorController.cs @@ -12,14 +12,14 @@ public CalculatorController(ILogger logger) { _logger = logger; } - public string Index(int first, int second,string sign) + public string Index(int first, int second, string sign) { switch (sign) { case "+": return $"{first} + {second} = {first + second}"; case "-": return $"{first} - {second} = {first - second}"; case "*": return $"{first} * {second} = {first * second}"; - default:return "неверный знак, попробуйте снова"; + default: return "неверный знак, попробуйте снова"; } } diff --git a/WebApplicationStart/Program.cs b/WebApplicationStart/Program.cs index 2fe731f..782ee59 100644 --- a/WebApplicationStart/Program.cs +++ b/WebApplicationStart/Program.cs @@ -18,6 +18,6 @@ app.MapControllerRoute( name: "default", - pattern: "{controller=Home}/{action=Index}/{first?}/{second?}/{sign=+}"); + pattern: "{controller=Home}/{action=Index}"); app.Run(); From a3826cb72f6cda0c6839721266a4497d124802e3 Mon Sep 17 00:00:00 2001 From: Ivanov Stas Date: Mon, 16 Mar 2026 23:17:32 +0300 Subject: [PATCH 5/5] =?UTF-8?q?Ivanov-4=D0=B7=D0=B0=D0=B4=D0=B0=D0=BD?= =?UTF-8?q?=D0=B8=D0=B5=20=D0=BF=D0=B5=D1=80=D0=B5=D0=B4=D0=B5=D0=BB=D0=B0?= =?UTF-8?q?=D0=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/CalcController.cs | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/WebApplicationStart/Controllers/CalcController.cs b/WebApplicationStart/Controllers/CalcController.cs index 1a35289..ef83209 100644 --- a/WebApplicationStart/Controllers/CalcController.cs +++ b/WebApplicationStart/Controllers/CalcController.cs @@ -14,16 +14,21 @@ public CalcController(ILogger logger) } public string Index(double a = 0, double b = 0, string c = "+") { - if (b == 0 && c == "/") - return "На ноль делить нельзя!"; - switch (c) + if (c == "+") + return $"{a} + {b} = {a + b}"; + else if (c == "-") + return $"{a} - {b} = {a - b}"; + else if (c == "*") + return $"{a} * {b} = {a * b}"; + else if (c == "/") { - case "+": return $"{a} + {b} = {a + b}"; - case "-": return $"{a} - {b} = {a - b}"; - case "*": return $"{a} * {b} = {a * b}"; - case "/": return $"{a} / {b} = {a / b}"; - default: return "неверный знак, попробуйте снова"; + if (b == 0) + return "На ноль делить нельзя!"; + else + return $"{a} / {b} = {a / b}"; } + else + return "неверный знак, попробуйте снова"; } [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]