PIbd-21_CourseWork_Polyclin.../Polyclinic/PolyclinicWebAppSuretor/Controllers/HomeController.cs

173 lines
4.7 KiB
C#

using Microsoft.AspNetCore.Mvc;
using PolyclinicBusinessLogic.BusinessLogics;
using PolyclinicContracts.BindingModels;
using PolyclinicContracts.BusinessLogicsContracts;
using PolyclinicContracts.SearchModels;
using PolyclinicContracts.ViewModels;
using PolyclinicWebAppSuretor.Models;
using System.Diagnostics;
namespace PolyclinicWebAppSuretor.Controllers
{
public class HomeController : Controller
{
private readonly ILogger<HomeController> _logger;
private readonly IProcedureLogic _procedureLogic;
public HomeController(ILogger<HomeController> logger, IProcedureLogic procedureLogic)
{
_logger = logger;
_procedureLogic = procedureLogic;
}
public IActionResult Index()
{
return View();
}
public IActionResult Privacy()
{
return View();
}
public IActionResult Medicaments()
{
return View();
}
public IActionResult Procedures()
{
List<ProcedureViewModel> procedure = _procedureLogic.ReadList(null);
if (procedure == null)
{
procedure = new();
}
return View(procedure);
}
public IActionResult Recipes()
{
return View();
}
public IActionResult CreateRecipe()
{
return View();
}
[HttpGet]
[HttpPost]
public IActionResult CreateProcedure(string name, string? comment, DateTime dateStart, DateTime? dateStop)
{
if (HttpContext.Request.Method == "GET")
{
ViewData["Title"] = "Íîâàÿ ïðîöåäóðà";
return View();
}
else
{
// TODO ïðîïèñàòü UserId
ProcedureBindingModel procedure = new ProcedureBindingModel
{
Name = name,
Comment = comment ?? string.Empty,
DateStartProcedure = dateStart,
DateStopProcedure = dateStop
};
_procedureLogic.Create(procedure);
return RedirectToAction("Procedures");
}
}
[HttpGet]
[HttpPost]
public IActionResult Edit(int id,string name, string comment, DateTime dateStart, DateTime? dateStop)
{
if (HttpContext.Request.Method == "GET")
{
var obj = _procedureLogic.ReadElement(new ProcedureSearchModel { Id = id });
ViewData["Title"] = "Ðåäàêòèðîâàòü ïðîöåäóðó";
return View(obj);
}
else
{
ProcedureBindingModel procedure = new ProcedureBindingModel
{
Id = id,
Name = name,
Comment = comment,
DateStartProcedure = dateStart,
DateStopProcedure = dateStop
};
_procedureLogic.Update(procedure);
return RedirectToAction("Procedures");
}
}
public IActionResult CreateMedicament()
{
return View();
}
public IActionResult ListCoursesByProcedures()
{
return View();
}
public IActionResult AddSymptomToMedicament()
{
return View();
}
[HttpGet]
[HttpPost]
public IActionResult ProceduresReport()
{
if (HttpContext.Request.Method == "POST")
{
ViewData["ShowReport"] = true;
return View();
}
else
{
return View();
}
}
[HttpGet]
[HttpPost]
public IActionResult Login()
{
if (HttpContext.Request.Method == "POST")
{
// êàêèå-òî äåéñòâèÿ ïðè íàæàòèè êíîïêè âõîäà
return View();
}
else
{
return View();
}
}
[HttpGet]
[HttpPost]
public IActionResult Register()
{
if (HttpContext.Request.Method == "POST")
{
// êàêèå-òî äåéñòâèÿ ïðè íàæàòèè êíîïêè
return View();
}
else
{
return View();
}
}
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
public IActionResult Error()
{
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
}
}
}