2024-04-30 16:53:50 +04:00
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
2024-05-26 18:16:46 +04:00
|
|
|
|
using PolyclinicBusinessLogic.BusinessLogics;
|
|
|
|
|
using PolyclinicContracts.BindingModels;
|
2024-05-26 13:45:07 +04:00
|
|
|
|
using PolyclinicContracts.BusinessLogicsContracts;
|
2024-05-26 18:16:46 +04:00
|
|
|
|
using PolyclinicContracts.SearchModels;
|
2024-05-26 13:45:07 +04:00
|
|
|
|
using PolyclinicContracts.ViewModels;
|
2024-05-28 16:55:59 +04:00
|
|
|
|
using PolyclinicDataModels.Models;
|
2024-04-30 16:53:50 +04:00
|
|
|
|
using PolyclinicWebAppSuretor.Models;
|
|
|
|
|
using System.Diagnostics;
|
|
|
|
|
|
|
|
|
|
namespace PolyclinicWebAppSuretor.Controllers
|
|
|
|
|
{
|
|
|
|
|
public class HomeController : Controller
|
|
|
|
|
{
|
|
|
|
|
private readonly ILogger<HomeController> _logger;
|
2024-05-26 13:45:07 +04:00
|
|
|
|
private readonly IProcedureLogic _procedureLogic;
|
2024-05-28 00:17:46 +04:00
|
|
|
|
private readonly IMedicamentLogic _medicamentLogic;
|
|
|
|
|
private readonly IRecipeLogic _recipeLogic;
|
|
|
|
|
private readonly ISymptomLogic _symptomLogic;
|
2024-05-28 16:55:59 +04:00
|
|
|
|
private readonly ICourseLogic _courseLogic;
|
2024-04-30 16:53:50 +04:00
|
|
|
|
|
2024-05-28 00:17:46 +04:00
|
|
|
|
public HomeController(ILogger<HomeController> logger,
|
|
|
|
|
IProcedureLogic procedureLogic,
|
|
|
|
|
IMedicamentLogic medicamentLogic,
|
|
|
|
|
IRecipeLogic recipeLogic,
|
2024-05-28 16:55:59 +04:00
|
|
|
|
ISymptomLogic symptomLogic,
|
|
|
|
|
ICourseLogic courseLogic)
|
2024-04-30 16:53:50 +04:00
|
|
|
|
{
|
|
|
|
|
_logger = logger;
|
2024-05-26 13:45:07 +04:00
|
|
|
|
_procedureLogic = procedureLogic;
|
2024-05-28 00:17:46 +04:00
|
|
|
|
_medicamentLogic = medicamentLogic;
|
|
|
|
|
_recipeLogic = recipeLogic;
|
|
|
|
|
_symptomLogic = symptomLogic;
|
2024-05-28 16:55:59 +04:00
|
|
|
|
_courseLogic = courseLogic;
|
2024-04-30 16:53:50 +04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IActionResult Index()
|
|
|
|
|
{
|
|
|
|
|
return View();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IActionResult Privacy()
|
|
|
|
|
{
|
|
|
|
|
return View();
|
|
|
|
|
}
|
|
|
|
|
|
2024-05-28 00:17:46 +04:00
|
|
|
|
public IActionResult Recipes()
|
|
|
|
|
{
|
|
|
|
|
List<RecipeViewModel> recipes = _recipeLogic.ReadList(null);
|
|
|
|
|
if (recipes == null)
|
|
|
|
|
{
|
|
|
|
|
recipes = new();
|
|
|
|
|
}
|
|
|
|
|
return View(recipes);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpGet]
|
|
|
|
|
[HttpPost]
|
2024-05-28 16:55:59 +04:00
|
|
|
|
public IActionResult CreateRecipe(RecipeModel model, int[] selectedProcedures)
|
2024-05-28 00:17:46 +04:00
|
|
|
|
{
|
2024-05-28 16:55:59 +04:00
|
|
|
|
ViewBag.Courses = _courseLogic.ReadList(null);
|
2024-05-28 00:17:46 +04:00
|
|
|
|
if (HttpContext.Request.Method == "GET")
|
|
|
|
|
{
|
|
|
|
|
ViewData["Title"] = "<22><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>";
|
2024-05-28 16:55:59 +04:00
|
|
|
|
model = new()
|
|
|
|
|
{
|
|
|
|
|
Procedures = _procedureLogic.ReadList(null).Select(x => (x, false)).ToList()
|
|
|
|
|
};
|
|
|
|
|
return View("CreateRecipe", model);
|
2024-05-28 00:17:46 +04:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2024-05-28 16:55:59 +04:00
|
|
|
|
var allProcedures = _procedureLogic.ReadList(null);
|
|
|
|
|
|
2024-05-28 00:17:46 +04:00
|
|
|
|
RecipeBindingModel recipe = new RecipeBindingModel
|
|
|
|
|
{
|
2024-05-28 16:55:59 +04:00
|
|
|
|
ProceduresCount = model.RecipeViewModel.ProceduresCount,
|
|
|
|
|
Comment = model.RecipeViewModel.Comment,
|
|
|
|
|
RecipeProcedures = selectedProcedures
|
|
|
|
|
.ToDictionary(
|
|
|
|
|
x => x,
|
|
|
|
|
x => allProcedures.Where(y => y.Id == x) as IProcedureModel
|
|
|
|
|
)
|
2024-05-28 00:17:46 +04:00
|
|
|
|
};
|
|
|
|
|
_recipeLogic.Create(recipe);
|
2024-05-28 16:55:59 +04:00
|
|
|
|
return RedirectToAction("Recipes");
|
2024-05-28 00:17:46 +04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
[HttpGet]
|
|
|
|
|
[HttpPost]
|
2024-05-28 16:55:59 +04:00
|
|
|
|
public IActionResult EditRecipe(int id, RecipeModel model, int[] selectedProcedures)
|
2024-05-28 00:17:46 +04:00
|
|
|
|
{
|
|
|
|
|
if (HttpContext.Request.Method == "GET")
|
|
|
|
|
{
|
2024-05-28 16:55:59 +04:00
|
|
|
|
var obj = _recipeLogic.ReadElement(new RecipeSearchModel { Id = id });
|
|
|
|
|
model = new()
|
|
|
|
|
{
|
|
|
|
|
RecipeViewModel = obj,
|
|
|
|
|
Procedures = _procedureLogic.ReadList(null).Select(x => (x, obj.RecipeProcedures.ContainsKey(x.Id))).ToList()
|
|
|
|
|
};
|
|
|
|
|
ViewData["Title"] = "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>";
|
|
|
|
|
return View("CreateRecipe", model);
|
2024-05-28 00:17:46 +04:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2024-05-28 16:55:59 +04:00
|
|
|
|
var allProcedures = _procedureLogic.ReadList(null);
|
|
|
|
|
|
|
|
|
|
RecipeBindingModel recipe = new RecipeBindingModel
|
2024-05-28 00:17:46 +04:00
|
|
|
|
{
|
2024-05-28 16:55:59 +04:00
|
|
|
|
Id = id,
|
|
|
|
|
ProceduresCount = model.RecipeViewModel.ProceduresCount,
|
|
|
|
|
Comment = model.RecipeViewModel.Comment,
|
|
|
|
|
RecipeProcedures = selectedProcedures
|
|
|
|
|
.ToDictionary(
|
|
|
|
|
x => x,
|
|
|
|
|
x => allProcedures.Where(y => y.Id == x) as IProcedureModel
|
|
|
|
|
)
|
2024-05-28 00:17:46 +04:00
|
|
|
|
};
|
2024-05-28 16:55:59 +04:00
|
|
|
|
_recipeLogic.Update(recipe);
|
|
|
|
|
return RedirectToAction("Recipes");
|
2024-05-28 00:17:46 +04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
[HttpPost]
|
|
|
|
|
public IActionResult DeleteRecipe(int id)
|
|
|
|
|
{
|
2024-05-28 16:55:59 +04:00
|
|
|
|
var obj = _recipeLogic.ReadElement(new RecipeSearchModel { Id = id });
|
2024-05-28 00:17:46 +04:00
|
|
|
|
if (obj != null)
|
|
|
|
|
{
|
2024-05-28 16:55:59 +04:00
|
|
|
|
_recipeLogic.Delete(new RecipeBindingModel { Id = obj.Id });
|
2024-05-28 00:17:46 +04:00
|
|
|
|
}
|
2024-05-28 16:55:59 +04:00
|
|
|
|
return RedirectToAction("Recipes");
|
2024-05-28 00:17:46 +04:00
|
|
|
|
}
|
|
|
|
|
|
2024-04-30 19:59:10 +04:00
|
|
|
|
public IActionResult Medicaments()
|
|
|
|
|
{
|
2024-05-28 00:17:46 +04:00
|
|
|
|
List<MedicamentViewModel> medicaments = _medicamentLogic.ReadList(null);
|
|
|
|
|
if (medicaments == null)
|
|
|
|
|
{
|
|
|
|
|
medicaments = new();
|
|
|
|
|
}
|
|
|
|
|
return View(medicaments);
|
2024-04-30 19:59:10 +04:00
|
|
|
|
}
|
|
|
|
|
|
2024-05-28 00:17:46 +04:00
|
|
|
|
[HttpGet]
|
|
|
|
|
[HttpPost]
|
|
|
|
|
public IActionResult CreateMedicament(MedicamentViewModel model)
|
2024-04-30 19:59:10 +04:00
|
|
|
|
{
|
2024-05-28 00:17:46 +04:00
|
|
|
|
ViewBag.Procedures = _procedureLogic.ReadList(null);
|
|
|
|
|
ViewBag.Symptomes = _symptomLogic.ReadList(null);
|
|
|
|
|
if (HttpContext.Request.Method == "GET")
|
2024-05-26 13:45:07 +04:00
|
|
|
|
{
|
2024-05-28 00:17:46 +04:00
|
|
|
|
ViewData["Title"] = "<22><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>";
|
|
|
|
|
return View();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// TODO <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> UserId
|
|
|
|
|
MedicamentBindingModel medicament = new MedicamentBindingModel
|
|
|
|
|
{
|
|
|
|
|
Name = model.Name,
|
|
|
|
|
Comment = model.Comment ?? string.Empty,
|
|
|
|
|
SymptomId = model.SymptomId,
|
|
|
|
|
ProcedureId = model.ProcedureId,
|
|
|
|
|
};
|
|
|
|
|
_medicamentLogic.Create(medicament);
|
|
|
|
|
return RedirectToAction("Medicaments");
|
2024-05-26 13:45:07 +04:00
|
|
|
|
}
|
2024-04-30 19:59:10 +04:00
|
|
|
|
}
|
|
|
|
|
|
2024-05-28 00:17:46 +04:00
|
|
|
|
[HttpGet]
|
|
|
|
|
[HttpPost]
|
|
|
|
|
public IActionResult EditMedicament(MedicamentViewModel model)
|
2024-04-30 19:59:10 +04:00
|
|
|
|
{
|
2024-05-28 21:53:46 +04:00
|
|
|
|
ViewBag.Procedures = _procedureLogic.ReadList(null);
|
|
|
|
|
ViewBag.Symptomes = _symptomLogic.ReadList(null);
|
2024-05-28 00:17:46 +04:00
|
|
|
|
if (HttpContext.Request.Method == "GET")
|
|
|
|
|
{
|
|
|
|
|
var obj = _medicamentLogic.ReadElement(new MedicamentSearchModel { Id = model.Id });
|
|
|
|
|
ViewData["Title"] = "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>";
|
|
|
|
|
return View("CreateMedicament", obj);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
MedicamentBindingModel medicament = new MedicamentBindingModel
|
|
|
|
|
{
|
|
|
|
|
Id = model.Id,
|
|
|
|
|
Name = model.Name,
|
|
|
|
|
Comment = model.Comment ?? string.Empty,
|
|
|
|
|
SymptomId = model.SymptomId,
|
|
|
|
|
ProcedureId = model.ProcedureId,
|
|
|
|
|
};
|
|
|
|
|
_medicamentLogic.Update(medicament);
|
|
|
|
|
return RedirectToAction("Medicaments");
|
|
|
|
|
}
|
2024-04-30 19:59:10 +04:00
|
|
|
|
}
|
|
|
|
|
|
2024-05-28 00:17:46 +04:00
|
|
|
|
[HttpPost]
|
|
|
|
|
public IActionResult DeleteMedicament(int id)
|
2024-04-30 21:24:45 +04:00
|
|
|
|
{
|
2024-05-28 00:17:46 +04:00
|
|
|
|
var obj = _medicamentLogic.ReadElement(new MedicamentSearchModel { Id = id });
|
|
|
|
|
if (obj != null)
|
|
|
|
|
{
|
|
|
|
|
_medicamentLogic.Delete(new MedicamentBindingModel { Id = obj.Id });
|
|
|
|
|
}
|
|
|
|
|
return RedirectToAction("Medicaments");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public IActionResult Procedures()
|
|
|
|
|
{
|
|
|
|
|
List<ProcedureViewModel> procedure = _procedureLogic.ReadList(null);
|
|
|
|
|
if (procedure == null)
|
|
|
|
|
{
|
|
|
|
|
procedure = new();
|
|
|
|
|
}
|
|
|
|
|
return View(procedure);
|
2024-04-30 21:24:45 +04:00
|
|
|
|
}
|
|
|
|
|
|
2024-05-26 18:16:46 +04:00
|
|
|
|
[HttpGet]
|
|
|
|
|
[HttpPost]
|
2024-05-27 21:27:51 +04:00
|
|
|
|
public IActionResult CreateProcedure(ProcedureViewModel model)
|
2024-05-01 00:55:32 +04:00
|
|
|
|
{
|
2024-05-26 18:16:46 +04:00
|
|
|
|
if (HttpContext.Request.Method == "GET")
|
|
|
|
|
{
|
|
|
|
|
ViewData["Title"] = "<22><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>";
|
|
|
|
|
return View();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// TODO <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> UserId
|
|
|
|
|
ProcedureBindingModel procedure = new ProcedureBindingModel
|
|
|
|
|
{
|
2024-05-27 21:27:51 +04:00
|
|
|
|
Name = model.Name,
|
|
|
|
|
Comment = model.Comment ?? string.Empty,
|
|
|
|
|
DateStartProcedure = model.DateStartProcedure,
|
|
|
|
|
DateStopProcedure = model.DateStopProcedure
|
2024-05-26 18:16:46 +04:00
|
|
|
|
};
|
|
|
|
|
_procedureLogic.Create(procedure);
|
|
|
|
|
return RedirectToAction("Procedures");
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-05-27 19:09:14 +04:00
|
|
|
|
|
2024-05-26 18:16:46 +04:00
|
|
|
|
[HttpGet]
|
|
|
|
|
[HttpPost]
|
2024-05-27 19:09:14 +04:00
|
|
|
|
public IActionResult EditProcedure(ProcedureViewModel model)
|
2024-05-26 18:16:46 +04:00
|
|
|
|
{
|
|
|
|
|
if (HttpContext.Request.Method == "GET")
|
|
|
|
|
{
|
2024-05-27 19:09:14 +04:00
|
|
|
|
var obj = _procedureLogic.ReadElement(new ProcedureSearchModel { Id = model.Id });
|
2024-05-26 18:16:46 +04:00
|
|
|
|
ViewData["Title"] = "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>";
|
2024-05-27 19:09:14 +04:00
|
|
|
|
return View("CreateProcedure", obj);
|
2024-05-26 18:16:46 +04:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ProcedureBindingModel procedure = new ProcedureBindingModel
|
|
|
|
|
{
|
2024-05-27 19:09:14 +04:00
|
|
|
|
Id = model.Id,
|
|
|
|
|
Name = model.Name,
|
|
|
|
|
Comment = model.Comment,
|
|
|
|
|
DateStartProcedure = model.DateStartProcedure,
|
|
|
|
|
DateStopProcedure = model.DateStopProcedure
|
2024-05-26 18:16:46 +04:00
|
|
|
|
};
|
|
|
|
|
_procedureLogic.Update(procedure);
|
|
|
|
|
return RedirectToAction("Procedures");
|
|
|
|
|
}
|
2024-05-01 00:55:32 +04:00
|
|
|
|
}
|
|
|
|
|
|
2024-05-27 21:27:51 +04:00
|
|
|
|
[HttpPost]
|
|
|
|
|
public IActionResult DeleteProcedure(int id)
|
|
|
|
|
{
|
|
|
|
|
var obj = _procedureLogic.ReadElement(new ProcedureSearchModel { Id = id });
|
|
|
|
|
if (obj != null)
|
|
|
|
|
{
|
|
|
|
|
_procedureLogic.Delete(new ProcedureBindingModel { Id = obj.Id });
|
|
|
|
|
}
|
|
|
|
|
return RedirectToAction("Procedures");
|
|
|
|
|
}
|
|
|
|
|
|
2024-05-01 14:47:46 +04:00
|
|
|
|
public IActionResult ListCoursesByProcedures()
|
|
|
|
|
{
|
2024-05-28 18:46:06 +04:00
|
|
|
|
List<ProcedureViewModel> procedures = _procedureLogic.ReadList(null);
|
|
|
|
|
return View(procedures);
|
2024-05-01 14:47:46 +04:00
|
|
|
|
}
|
2024-05-01 00:55:32 +04:00
|
|
|
|
|
2024-05-28 18:46:06 +04:00
|
|
|
|
public IActionResult AddSymptomToMedicament(AddSymptomToMedicamentModel model)
|
2024-05-01 18:01:42 +04:00
|
|
|
|
{
|
2024-05-28 18:46:06 +04:00
|
|
|
|
model = new()
|
|
|
|
|
{
|
|
|
|
|
Medicaments = _medicamentLogic.ReadList(null),
|
|
|
|
|
Symptoms = _symptomLogic.ReadList(null)
|
|
|
|
|
};
|
|
|
|
|
return View(model);
|
2024-05-01 18:01:42 +04:00
|
|
|
|
}
|
2024-05-27 19:09:14 +04:00
|
|
|
|
|
2024-05-01 18:01:42 +04:00
|
|
|
|
[HttpGet]
|
|
|
|
|
[HttpPost]
|
|
|
|
|
public IActionResult ProceduresReport()
|
|
|
|
|
{
|
|
|
|
|
if (HttpContext.Request.Method == "POST")
|
|
|
|
|
{
|
|
|
|
|
ViewData["ShowReport"] = true;
|
|
|
|
|
return View();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return View();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-05-01 15:18:32 +04:00
|
|
|
|
[HttpGet]
|
|
|
|
|
[HttpPost]
|
|
|
|
|
public IActionResult Login()
|
|
|
|
|
{
|
|
|
|
|
if (HttpContext.Request.Method == "POST")
|
|
|
|
|
{
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD>-<2D><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
return View();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return View();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-05-01 15:42:24 +04:00
|
|
|
|
[HttpGet]
|
|
|
|
|
[HttpPost]
|
|
|
|
|
public IActionResult Register()
|
|
|
|
|
{
|
|
|
|
|
if (HttpContext.Request.Method == "POST")
|
|
|
|
|
{
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD>-<2D><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
return View();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return View();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-04-30 16:53:50 +04:00
|
|
|
|
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
|
|
|
|
|
public IActionResult Error()
|
|
|
|
|
{
|
|
|
|
|
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|