From 87dc0aa0431194a8c1a6bab2039f44d1251f062d Mon Sep 17 00:00:00 2001 From: flex12312 Date: Thu, 26 Feb 2026 11:26:07 +0300 Subject: [PATCH 1/4] =?UTF-8?q?=D0=A0=D0=B5=D1=88=D0=B5=D0=BD=D0=B8=D0=B5?= =?UTF-8?q?=20task1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WebApplicationStart/Controllers/HomeController.cs | 15 ++++++++++++++- WebApplicationStart/Views/Home/Index.cshtml | 2 +- WebApplicationStart/Views/Home/Tasks.cshtml | 2 +- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/WebApplicationStart/Controllers/HomeController.cs b/WebApplicationStart/Controllers/HomeController.cs index 610fb55..be9f8e9 100644 --- a/WebApplicationStart/Controllers/HomeController.cs +++ b/WebApplicationStart/Controllers/HomeController.cs @@ -26,7 +26,20 @@ public IActionResult Tasks() public string Task1() { - return "Тут решение первой задачи"; + int hour = DateTime.Now.Hour; + if (hour < 6) + { + return "Доброй ночи"; + } + if (hour < 12) + { + return "Доброе утро"; + } + if (hour < 18) + { + return "Добрый день"; + } + return "Добрый вечер"; } [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] diff --git a/WebApplicationStart/Views/Home/Index.cshtml b/WebApplicationStart/Views/Home/Index.cshtml index 28d6e5f..c3bc31b 100644 --- a/WebApplicationStart/Views/Home/Index.cshtml +++ b/WebApplicationStart/Views/Home/Index.cshtml @@ -3,7 +3,7 @@ }
-

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

+

Тавказахов Давид

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

diff --git a/WebApplicationStart/Views/Home/Tasks.cshtml b/WebApplicationStart/Views/Home/Tasks.cshtml index a167f22..077104f 100644 --- a/WebApplicationStart/Views/Home/Tasks.cshtml +++ b/WebApplicationStart/Views/Home/Tasks.cshtml @@ -5,7 +5,7 @@

    -
  • Задача 1. Время суток
  • +
  • Задача 1. Время суток
  • Задача 2. Калькулятор
  • Задача 3. Калькулятор с операцией
  • Задача 4. Калькулятор с операцией и query параметрами
  • From cca80609933e0445699e8b15556c600c9492eb47 Mon Sep 17 00:00:00 2001 From: flex12312 Date: Thu, 26 Feb 2026 11:35:11 +0300 Subject: [PATCH 2/4] =?UTF-8?q?=D0=A0=D0=B5=D1=88=D0=B5=D0=BD=D0=B8=D0=B5?= =?UTF-8?q?=20task2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WebApplicationStart/Controllers/HomeController.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/WebApplicationStart/Controllers/HomeController.cs b/WebApplicationStart/Controllers/HomeController.cs index be9f8e9..d54e089 100644 --- a/WebApplicationStart/Controllers/HomeController.cs +++ b/WebApplicationStart/Controllers/HomeController.cs @@ -42,6 +42,12 @@ public string Task1() return "Добрый вечер"; } + [Route("calculator/index/{n1?}/{n2?}")] + public string Task2(int n1 = 0, int n2 = 0) + { + return $"{n1} + {n2} = {n1 + n2}"; + } + [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] public IActionResult Error() { From c5c39e50e1b5f1095ca75f99b92e072120b4e80b Mon Sep 17 00:00:00 2001 From: flex12312 Date: Thu, 26 Feb 2026 11:45:45 +0300 Subject: [PATCH 3/4] =?UTF-8?q?=D0=A0=D0=B5=D1=88=D0=B5=D0=BD=D0=B8=D0=B5?= =?UTF-8?q?=20Task3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/HomeController.cs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/WebApplicationStart/Controllers/HomeController.cs b/WebApplicationStart/Controllers/HomeController.cs index d54e089..68f5c39 100644 --- a/WebApplicationStart/Controllers/HomeController.cs +++ b/WebApplicationStart/Controllers/HomeController.cs @@ -1,4 +1,5 @@ using Microsoft.AspNetCore.Mvc; +using System.Collections.Generic; using System.Diagnostics; using WebApplicationStart.Models; @@ -48,6 +49,21 @@ public string Task2(int n1 = 0, int n2 = 0) return $"{n1} + {n2} = {n1 + n2}"; } + [Route("calculator/index/{n1?}/{n2?}/{oper?}")] + public string Task3(double n1 = 0, double n2 = 0, string oper = "+") + { + double res = 0; + switch (oper) + { + case "+": res = n1 + n2; break; + case "-": res = n1 - n2; break; + case "*": res = n1 * n2; break; + case "/": res = n1 / n2; break; + default: return "Ошибка: Некорректная операция. Допустимые операции: +, -, *\rПример корректного запроса: https://localhost:7299/calculator/index/1/3/+"; + } + return $"{n1} {oper} {n2} = {res}"; + } + [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] public IActionResult Error() { From f6b50f3e265db98af70a59710976b3f304542a4f Mon Sep 17 00:00:00 2001 From: flex12312 Date: Thu, 26 Feb 2026 16:58:08 +0300 Subject: [PATCH 4/4] =?UTF-8?q?=D0=A0=D0=B5=D1=88=D0=B5=D0=BD=D0=B8=D0=B5?= =?UTF-8?q?=20Task4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/HomeController.cs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/WebApplicationStart/Controllers/HomeController.cs b/WebApplicationStart/Controllers/HomeController.cs index 68f5c39..0d49d27 100644 --- a/WebApplicationStart/Controllers/HomeController.cs +++ b/WebApplicationStart/Controllers/HomeController.cs @@ -64,6 +64,24 @@ public string Task3(double n1 = 0, double n2 = 0, string oper = "+") return $"{n1} {oper} {n2} = {res}"; } + [Route("calc/index")] + public string Task4(double a = 0, double b = 0, string c = "+") + { + c = System.Net.WebUtility.UrlDecode(c); + double res = 0; + switch (c) + { + case "+": res = a + b; break; + case "-": res = a - b; break; + case "*": res = a * b; break; + case "/": if (b == 0) return "Ошибка: Деление на ноль невозможно"; res = a / b; break; + default: return "Ошибка: Некорректная операция. Допустимые операции: +, -, *, /\rПример: https://localhost:5001/calc/index?a=1&b=3&c=+"; + } + return $"{a} {c} {b} = {res}"; + } + + + [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] public IActionResult Error() {