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?}"); }); } }