174 lines
4.7 KiB
C#
174 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 EditProcedure(ProcedureViewModel model)
|
|
{
|
|
if (HttpContext.Request.Method == "GET")
|
|
{
|
|
var obj = _procedureLogic.ReadElement(new ProcedureSearchModel { Id = model.Id });
|
|
ViewData["Title"] = "Ðåäàêòèðîâàòü ïðîöåäóðó";
|
|
return View("CreateProcedure", obj);
|
|
}
|
|
else
|
|
{
|
|
ProcedureBindingModel procedure = new ProcedureBindingModel
|
|
{
|
|
Id = model.Id,
|
|
Name = model.Name,
|
|
Comment = model.Comment,
|
|
DateStartProcedure = model.DateStartProcedure,
|
|
DateStopProcedure = model.DateStopProcedure
|
|
};
|
|
_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 });
|
|
}
|
|
}
|
|
}
|