From 52a69e3537968ffc2820cde84f9895f0fc00535f Mon Sep 17 00:00:00 2001 From: Sasha Date: Fri, 5 Apr 2024 00:52:48 +0300 Subject: [PATCH] =?UTF-8?q?=D1=83=D0=BA=D0=B0=D0=B7=D1=8B=D0=B2=D0=B0?= =?UTF-8?q?=D0=B5=D1=82=20=D1=82=D0=B5=D0=BA=D1=83=D1=89=D0=B5=D0=B5=20?= =?UTF-8?q?=D0=B2=D1=80=D0=B5=D0=BC=D1=8F=20=D1=81=D1=83=D1=82=D0=BE=D0=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/HomeController.cs | 5 +++ .../Controllers/StartController.cs | 35 +++++++++++++++++++ WebApplicationLesson1/Startup.cs | 2 +- 3 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 WebApplicationLesson1/Controllers/StartController.cs diff --git a/WebApplicationLesson1/Controllers/HomeController.cs b/WebApplicationLesson1/Controllers/HomeController.cs index e915d40..583b2f6 100644 --- a/WebApplicationLesson1/Controllers/HomeController.cs +++ b/WebApplicationLesson1/Controllers/HomeController.cs @@ -22,6 +22,11 @@ public IActionResult Index() { return View(); } + public string Hello() + { + DateTime timeOfDay = new DateTime(); + return Convert.ToString(timeOfDay); + } public IActionResult Privacy() { diff --git a/WebApplicationLesson1/Controllers/StartController.cs b/WebApplicationLesson1/Controllers/StartController.cs new file mode 100644 index 0000000..13fe419 --- /dev/null +++ b/WebApplicationLesson1/Controllers/StartController.cs @@ -0,0 +1,35 @@ +using Microsoft.AspNetCore.Mvc; +using System; + + +namespace WebApplicationLesson1.Controllers +{ + public class StartController : Controller + { + public string Hello() + { + var currentHour = DateTime.Now.Hour; + if (currentHour >= 0 && currentHour < 6) + { + return "Доброй ночи"; + } + + if (currentHour >= 6 && currentHour < 12) + { + return "Доброе утро"; + } + + if (currentHour >= 12 && currentHour < 18) + { + return "Доброй день"; + } + + + { + return "Доброй вечер"; + } + + + } + } +} diff --git a/WebApplicationLesson1/Startup.cs b/WebApplicationLesson1/Startup.cs index d9a1eb0..b393292 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}/{id?}"); }); } }