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
5 changes: 5 additions & 0 deletions WebApplicationLesson1/Controllers/HomeController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ public IActionResult Index()
{
return View();
}
public string Hello()
{
DateTime timeOfDay = new DateTime();
return Convert.ToString(timeOfDay);
}

public IActionResult Privacy()
{
Expand Down
35 changes: 35 additions & 0 deletions WebApplicationLesson1/Controllers/StartController.cs
Original file line number Diff line number Diff line change
@@ -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 "Доброй вечер";
}


}
}
}
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}/{id?}");
});
}
}
Expand Down