This commit is contained in:
Никита Потапов 2024-05-29 12:55:44 +04:00
commit 92e74d1d7d
10 changed files with 66 additions and 38 deletions

View File

@ -66,7 +66,7 @@ namespace PolyclinicBusinessLogic.BusinessLogics
if (list == null) if (list == null)
{ {
logger.LogWarning("ReadList return null list"); logger.LogWarning("ReadList return null list");
return null; return new List<ProcedureViewModel>();
} }
logger.LogInformation("ReadList. Count:{Count}", list.Count); logger.LogInformation("ReadList. Count:{Count}", list.Count);
return list; return list;

View File

@ -58,14 +58,14 @@ namespace PolyclinicBusinessLogic.BusinessLogics
return element; return element;
} }
public List<RecipeViewModel>? ReadList(RecipeSearchModel? model) public List<RecipeViewModel>? ReadList(RecipeSearchModel? model = null)
{ {
logger.LogInformation("ReadList. Comment:{Comment}. Id:{ Id}", model?.Comment, model?.Id); logger.LogInformation("ReadList. Comment:{Comment}. Id:{ Id}", model?.Comment, model?.Id);
var list = model == null ? recipeStorage.GetFullList() : recipeStorage.GetFilteredList(model); var list = model == null ? recipeStorage.GetFullList() : recipeStorage.GetFilteredList(model);
if (list == null) if (list == null)
{ {
logger.LogWarning("ReadList return null list"); logger.LogWarning("ReadList return null list");
return null; return new List<RecipeViewModel>();
} }
logger.LogInformation("ReadList. Count:{Count}", list.Count); logger.LogInformation("ReadList. Count:{Count}", list.Count);
return list; return list;

View File

@ -26,7 +26,7 @@ namespace PolyclinicBusinessLogic.OfficePackage
{ {
Texts = new List<(string, WordTextProperties)> Texts = new List<(string, WordTextProperties)>
{ {
("Количество пилюль в день: " + course.PillsPerDay.ToString() + " единиц", new WordTextProperties{ Size = "24"}), ("Количество пилюль в день: " + course.PillsPerDay.ToString() + " единиц\t", new WordTextProperties{ Size = "24"}),
("Количество дней приёма: " + course.DaysCount.ToString() + " дней", new WordTextProperties{ Size = "24"}), ("Количество дней приёма: " + course.DaysCount.ToString() + " дней", new WordTextProperties{ Size = "24"}),
}, },

View File

@ -6,7 +6,7 @@ namespace PolyclinicContracts.BusinessLogicsContracts
{ {
public interface IProcedureLogic public interface IProcedureLogic
{ {
List<ProcedureViewModel>? ReadList(ProcedureSearchModel? model); List<ProcedureViewModel>? ReadList(ProcedureSearchModel? model = null);
ProcedureViewModel? ReadElement(ProcedureSearchModel model); ProcedureViewModel? ReadElement(ProcedureSearchModel model);
bool Create(ProcedureBindingModel model); bool Create(ProcedureBindingModel model);
bool Update(ProcedureBindingModel model); bool Update(ProcedureBindingModel model);

View File

@ -6,7 +6,7 @@ namespace PolyclinicContracts.BusinessLogicsContracts
{ {
public interface IRecipeLogic public interface IRecipeLogic
{ {
List<RecipeViewModel>? ReadList(RecipeSearchModel? model); List<RecipeViewModel>? ReadList(RecipeSearchModel? model = null);
RecipeViewModel? ReadElement(RecipeSearchModel model); RecipeViewModel? ReadElement(RecipeSearchModel model);
bool Create(RecipeBindingModel model); bool Create(RecipeBindingModel model);
bool Update(RecipeBindingModel model); bool Update(RecipeBindingModel model);

View File

@ -20,6 +20,7 @@ namespace PolyclinicWebAppSuretor.Controllers
private readonly ISymptomLogic _symptomLogic; private readonly ISymptomLogic _symptomLogic;
private readonly ICourseLogic _courseLogic; private readonly ICourseLogic _courseLogic;
private readonly ISuretorReportLogic _suretorReportLogic; private readonly ISuretorReportLogic _suretorReportLogic;
private readonly IUserLogic _userLogic;
public HomeController(ILogger<HomeController> logger, public HomeController(ILogger<HomeController> logger,
IProcedureLogic procedureLogic, IProcedureLogic procedureLogic,
@ -27,7 +28,8 @@ namespace PolyclinicWebAppSuretor.Controllers
IRecipeLogic recipeLogic, IRecipeLogic recipeLogic,
ISymptomLogic symptomLogic, ISymptomLogic symptomLogic,
ICourseLogic courseLogic, ICourseLogic courseLogic,
ISuretorReportLogic suretorReportLogic) ISuretorReportLogic suretorReportLogic,
IUserLogic userLogic)
{ {
_logger = logger; _logger = logger;
_procedureLogic = procedureLogic; _procedureLogic = procedureLogic;
@ -36,6 +38,7 @@ namespace PolyclinicWebAppSuretor.Controllers
_symptomLogic = symptomLogic; _symptomLogic = symptomLogic;
_courseLogic = courseLogic; _courseLogic = courseLogic;
_suretorReportLogic = suretorReportLogic; _suretorReportLogic = suretorReportLogic;
_userLogic = userLogic;
} }
public IActionResult Index() public IActionResult Index()
@ -48,6 +51,36 @@ namespace PolyclinicWebAppSuretor.Controllers
return View(); return View();
} }
[HttpGet]
[HttpPost]
public IActionResult Register(RegisterModel model)
{
var errors = new List<string>();
if (HttpContext.Request.Method == "POST")
{
var userEmail = _userLogic.ReadElement(new UserSearchModel { Email = model.Email });
if (userEmail != null) errors.Add("Ýòîò Email óæå çàðåãèñòèðîâàí");
if (model.Password != model.ConfirmPassword) errors.Add("Ïàðîëè íå ñîâïàäàþò");
if (errors.Count > 0)
{
model.Errors = errors;
model.Email = string.Empty;
model.ConfirmPassword = string.Empty;
model.FIO = model.FIO;
return View(model);
}
/*var user = new UserViewModel {
Email
};*/
return RedirectToAction("Login");
}
else
{
return View();
}
}
/// <summary> /// <summary>
/// RECIPES /// RECIPES
/// </summary> /// </summary>
@ -73,7 +106,7 @@ namespace PolyclinicWebAppSuretor.Controllers
ViewData["Title"] = "Íîâûé ðåöåïò"; ViewData["Title"] = "Íîâûé ðåöåïò";
model = new() model = new()
{ {
Procedures = _procedureLogic.ReadList(null).Select(x => (x, false)).ToList() Procedures = _procedureLogic.ReadList().Select(x => (x, false)).ToList()
}; };
return View("CreateRecipe", model); return View("CreateRecipe", model);
} }
@ -89,7 +122,7 @@ namespace PolyclinicWebAppSuretor.Controllers
RecipeProcedures = selectedProcedures RecipeProcedures = selectedProcedures
.ToDictionary( .ToDictionary(
x => x, x => x,
x => allProcedures.First(y => y.Id == x) as IProcedureModel x => allProcedures.Where(y => y.Id == x) as IProcedureModel
) )
}; };
@ -101,15 +134,17 @@ namespace PolyclinicWebAppSuretor.Controllers
[HttpPost] [HttpPost]
public IActionResult EditRecipe(int id, RecipeModel model, int[] selectedProcedures) public IActionResult EditRecipe(int id, RecipeModel model, int[] selectedProcedures)
{ {
ViewBag.Courses = _courseLogic.ReadList();
if (HttpContext.Request.Method == "GET") if (HttpContext.Request.Method == "GET")
{ {
var obj = _recipeLogic.ReadElement(new RecipeSearchModel { Id = id }); var obj = _recipeLogic.ReadElement(new RecipeSearchModel { Id = id });
model = new() model = new()
{ {
RecipeViewModel = obj, RecipeViewModel = obj,
Procedures = _procedureLogic.ReadList(null).Select(x => (x, obj.RecipeProcedures.ContainsKey(x.Id))).ToList() Procedures = _procedureLogic.ReadList().Select(x => (x, obj.RecipeProcedures.ContainsKey(x.Id))).ToList()
}; };
ViewData["Title"] = "Ðåäàêòèðîâàòü ñèìïòîì"; ViewData["Title"] = "Ðåäàêòèðîâàòü ðåöåïò";
return View("CreateRecipe", model); return View("CreateRecipe", model);
} }
else else
@ -125,7 +160,7 @@ namespace PolyclinicWebAppSuretor.Controllers
RecipeProcedures = selectedProcedures RecipeProcedures = selectedProcedures
.ToDictionary( .ToDictionary(
x => x, x => x,
x => allProcedures.First(y => y.Id == x) as IProcedureModel x => allProcedures.Where(y => y.Id == x) as IProcedureModel
) )
}; };
_recipeLogic.Update(recipe); _recipeLogic.Update(recipe);
@ -372,21 +407,6 @@ namespace PolyclinicWebAppSuretor.Controllers
} }
} }
[HttpGet]
[HttpPost]
public IActionResult Register()
{
if (HttpContext.Request.Method == "POST")
{
// êàêèå-òî äåéñòâèÿ ïðè íàæàòèè êíîïêè
return View();
}
else
{
return View();
}
}
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
public IActionResult Error() public IActionResult Error()
{ {

View File

@ -14,10 +14,12 @@ builder.Logging.AddLog4Net("log4net.config");
builder.Services.AddTransient<IProcedureLogic, ProcedureLogic>(); builder.Services.AddTransient<IProcedureLogic, ProcedureLogic>();
builder.Services.AddTransient<IMedicamentLogic, MedicamentLogic>(); builder.Services.AddTransient<IMedicamentLogic, MedicamentLogic>();
builder.Services.AddTransient<IRecipeLogic, RecipeLogic>(); builder.Services.AddTransient<IRecipeLogic, RecipeLogic>();
builder.Services.AddTransient<IUserLogic, UserLogic>();
builder.Services.AddTransient<IProcedureStorage, ProcedureStorage>(); builder.Services.AddTransient<IProcedureStorage, ProcedureStorage>();
builder.Services.AddTransient<IMedicamentStorage, MedicamentStorage>(); builder.Services.AddTransient<IMedicamentStorage, MedicamentStorage>();
builder.Services.AddTransient<IRecipeStorage, RecipeStorage>(); builder.Services.AddTransient<IRecipeStorage, RecipeStorage>();
builder.Services.AddTransient<IUserStorage, UserStorage>();
builder.Services.AddTransient<AbstractSaveToWordCoursesByProcedures, SaveToWordCoursesByProcedure>(); builder.Services.AddTransient<AbstractSaveToWordCoursesByProcedures, SaveToWordCoursesByProcedure>();
builder.Services.AddTransient<ISuretorReportLogic, SuretorReportLogic>(); builder.Services.AddTransient<ISuretorReportLogic, SuretorReportLogic>();

View File

@ -1,5 +1,6 @@
@using PolyclinicContracts.ViewModels @using PolyclinicContracts.ViewModels
@model RecipeModel @model RecipeModel
<h4>@ViewData["Title"]</h4>
<div class="text-center mt-3 mb-3"> <div class="text-center mt-3 mb-3">
<h2 class="display-4">@ViewData["Title"]</h2> <h2 class="display-4">@ViewData["Title"]</h2>

View File

@ -1,6 +1,5 @@
@{ @model RegisterModel
ViewBag.SelectedSiteMenuItem = SiteMenuItems.Register;
}
<div class="d-flex w-100 h-100 align-content-center justify-content-center align-items-center mt-5 pt-5"> <div class="d-flex w-100 h-100 align-content-center justify-content-center align-items-center mt-5 pt-5">
<form class="d-flex flex-column border border-success border-3 rounded-3 p-5" id="loginForm" method="post"> <form class="d-flex flex-column border border-success border-3 rounded-3 p-5" id="loginForm" method="post">
<h4>Регистрация</h4> <h4>Регистрация</h4>
@ -8,19 +7,25 @@
<label for="fioInput" class="pe-3 w-25"> <label for="fioInput" class="pe-3 w-25">
ФИО ФИО
</label> </label>
<input class="w-100" type="text" name="fio" id="fioInput" placeholder="Иванов Иван Иванович" /> <input class="w-100" type="text" name="fio" id="fioInput" placeholder="Иванов Иван Иванович" asp-for="FIO" />
</div> </div>
<div class="d-flex mb-3"> <div class="d-flex mb-3">
<label for="emailInput" class="pe-3 w-25"> <label for="emailInput" class="pe-3 w-25">
Email Email
</label> </label>
<input class="w-100" type="email" name="email" id="emailInput" placeholder="mail@example.com" /> <input class="w-100" type="email" name="email" id="emailInput" placeholder="mail@example.com" asp-for="Email" />
</div> </div>
<div class="d-flex mb-3"> <div class="d-flex mb-3">
<label for="passwordInput" class="pe-3 w-50"> <label for="passwordInput" class="pe-3 w-50">
Пароль Пароль
</label> </label>
<input class="w-100" type="password" name="password" id="passwordInput" /> <input class="w-100" type="password" name="password" id="passwordInput" asp-for="Password" />
</div>
<div class="d-flex mb-3">
<label for="passwordConfirm" class="pe-3 w-50">
Подверждение пароля
</label>
<input class="w-100" type="password" name="passwordConfirm" id="passwordConfirm" asp-for="ConfirmPassword" />
</div> </div>
<button class="btn btn-outline-success" type="submit"> <button class="btn btn-outline-success" type="submit">
Зарегистрироваться Зарегистрироваться

View File

@ -54,7 +54,7 @@
<footer class="border-top footer text-muted"> <footer class="border-top footer text-muted">
<div class="container"> <div class="container">
&copy; 2024 - PolyclinicWebView - <a asp-area="" asp-controller="Home" asp-action="Privacy">Privacy</a> &copy; 2024 - Поликлиника "Будьте больны" - <a asp-area="" asp-controller="Home" asp-action="Privacy">Политика конфедициальности</a>
</div> </div>
</footer> </footer>
<script src="~/lib/jquery/dist/jquery.min.js"></script> <script src="~/lib/jquery/dist/jquery.min.js"></script>