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
40 changes: 40 additions & 0 deletions WebApplicationStart/Controllers/CalcController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
using Microsoft.AspNetCore.Mvc;
using System.Diagnostics;
using WebApplicationStart.Models;

namespace WebApplicationStart.Controllers
{
public class CalcController : Controller
{
private readonly ILogger<HomeController> _logger;

public CalcController(ILogger<HomeController> logger)
{
_logger = logger;
}
public string Index(double a = 0, double b = 0, string 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 == "/")
{
if (b == 0)
return "На ноль делить нельзя!";
else
return $"{a} / {b} = {a / b}";
}
else
return "неверный знак, попробуйте снова";
}

[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
public IActionResult Error()
{
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
}
}
}
32 changes: 32 additions & 0 deletions WebApplicationStart/Controllers/CalculatorController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using Microsoft.AspNetCore.Mvc;
using System.Diagnostics;
using WebApplicationStart.Models;

namespace WebApplicationStart.Controllers
{
public class CalculatorController : Controller
{
private readonly ILogger<HomeController> _logger;

public CalculatorController(ILogger<HomeController> logger)
{
_logger = logger;
}
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 "неверный знак, попробуйте снова";
}
}

[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
public IActionResult Error()
{
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
}
}
}
32 changes: 32 additions & 0 deletions WebApplicationStart/Controllers/StartController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using Microsoft.AspNetCore.Mvc;
using System.Diagnostics;
using WebApplicationStart.Models;

namespace WebApplicationStart.Controllers
{
public class StartController : Controller
{
private readonly ILogger<HomeController> _logger;

public StartController(ILogger<HomeController> 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 });
}
}
}
2 changes: 1 addition & 1 deletion WebApplicationStart/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@

app.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}");
pattern: "{controller=Home}/{action=Index}");

app.Run();
2 changes: 1 addition & 1 deletion WebApplicationStart/Views/Home/Index.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
}

<div class="text-center">
<h1 class="display-4">Тут надо написать свою Фамилию и Имя</h1>
<h1 class="display-4">Иванов Станислав</h1>
<p>Я учу ASP и это мой первый крутой проект.</p>
<div>
<img class="img-fluid" src="images/startdevelopweb.png"> </img>
Expand Down