Добавил проверку на POST запросы в контроллер

This commit is contained in:
Никита Потапов 2024-04-30 17:27:10 +04:00
parent 04141a7abf
commit 4c3d34d57a
2 changed files with 30 additions and 7 deletions

View File

@ -17,9 +17,18 @@ namespace PolyclinicWebAppImplementer.Controllers
{
return View();
}
[HttpGet]
[HttpPost]
public IActionResult Course()
{
return View();
if (HttpContext.Request.Method == "POST")
{
return Redirect("~/Home/Courses");
}
else
{
return View();
}
}
public IActionResult Courses()
{
@ -27,7 +36,14 @@ namespace PolyclinicWebAppImplementer.Controllers
}
public IActionResult Diagnose()
{
return View();
if (HttpContext.Request.Method == "POST")
{
return Redirect("~/Home/Diagnoses");
}
else
{
return View();
}
}
public IActionResult Diagnoses()
@ -36,7 +52,14 @@ namespace PolyclinicWebAppImplementer.Controllers
}
public IActionResult Symptom()
{
return View();
if (HttpContext.Request.Method == "POST")
{
return Redirect("~/Home/Symptomes");
}
else
{
return View();
}
}
public IActionResult Symptomes()
{

View File

@ -4,7 +4,7 @@
@{
ViewBag.SelectedSiteMenuItem = SiteMenuItems.Course;
}
<form class="d-flex flex-column">
<form class="d-flex flex-column" method="post">
<div class="row mb-5">
<div class="col-3">Количество дней:</div>
<div class="col-8"><input type="number" id="daysCount" name="daysCount" /></div>
@ -21,16 +21,16 @@
<div class="col-3">Рецепт:</div>
<div class="col-8">
<select id="recipeId" name="recipeId">
<option>Выберите рецепт</option>
<option value="">Выберите рецепт</option>
<option value="0">Какой-то рецепт</option>
</select>
</div>
</div>
<div class="row mb-5">
<div class="col-4">
<a class="btn btn-success">
<button class="btn btn-success" type="submit">
Сохранить
</a>
</button>
<a class="btn btn-danger">
Отмена
</a>