diff --git a/Polyclinic/PolyclinicBusinessLogic/BusinessLogics/ProcedureLogic.cs b/Polyclinic/PolyclinicBusinessLogic/BusinessLogics/ProcedureLogic.cs index 789738b..4b4bf9e 100644 --- a/Polyclinic/PolyclinicBusinessLogic/BusinessLogics/ProcedureLogic.cs +++ b/Polyclinic/PolyclinicBusinessLogic/BusinessLogics/ProcedureLogic.cs @@ -66,7 +66,7 @@ namespace PolyclinicBusinessLogic.BusinessLogics if (list == null) { logger.LogWarning("ReadList return null list"); - return null; + return new List(); } logger.LogInformation("ReadList. Count:{Count}", list.Count); return list; diff --git a/Polyclinic/PolyclinicBusinessLogic/BusinessLogics/RecipeLogic.cs b/Polyclinic/PolyclinicBusinessLogic/BusinessLogics/RecipeLogic.cs index eb9228f..d14c951 100644 --- a/Polyclinic/PolyclinicBusinessLogic/BusinessLogics/RecipeLogic.cs +++ b/Polyclinic/PolyclinicBusinessLogic/BusinessLogics/RecipeLogic.cs @@ -58,14 +58,14 @@ namespace PolyclinicBusinessLogic.BusinessLogics return element; } - public List? ReadList(RecipeSearchModel? model) + public List? ReadList(RecipeSearchModel? model = null) { logger.LogInformation("ReadList. Comment:{Comment}. Id:{ Id}", model?.Comment, model?.Id); var list = model == null ? recipeStorage.GetFullList() : recipeStorage.GetFilteredList(model); if (list == null) { logger.LogWarning("ReadList return null list"); - return null; + return new List(); } logger.LogInformation("ReadList. Count:{Count}", list.Count); return list; diff --git a/Polyclinic/PolyclinicBusinessLogic/OfficePackage/AbstractSaveToWordCoursesByProcedures.cs b/Polyclinic/PolyclinicBusinessLogic/OfficePackage/AbstractSaveToWordCoursesByProcedures.cs index 62e610a..d513b5d 100644 --- a/Polyclinic/PolyclinicBusinessLogic/OfficePackage/AbstractSaveToWordCoursesByProcedures.cs +++ b/Polyclinic/PolyclinicBusinessLogic/OfficePackage/AbstractSaveToWordCoursesByProcedures.cs @@ -26,7 +26,7 @@ namespace PolyclinicBusinessLogic.OfficePackage { 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"}), }, diff --git a/Polyclinic/PolyclinicContracts/BusinessLogicsContracts/IProcedureLogic.cs b/Polyclinic/PolyclinicContracts/BusinessLogicsContracts/IProcedureLogic.cs index 9928c08..43133a7 100644 --- a/Polyclinic/PolyclinicContracts/BusinessLogicsContracts/IProcedureLogic.cs +++ b/Polyclinic/PolyclinicContracts/BusinessLogicsContracts/IProcedureLogic.cs @@ -6,7 +6,7 @@ namespace PolyclinicContracts.BusinessLogicsContracts { public interface IProcedureLogic { - List? ReadList(ProcedureSearchModel? model); + List? ReadList(ProcedureSearchModel? model = null); ProcedureViewModel? ReadElement(ProcedureSearchModel model); bool Create(ProcedureBindingModel model); bool Update(ProcedureBindingModel model); diff --git a/Polyclinic/PolyclinicContracts/BusinessLogicsContracts/IRecipeLogic.cs b/Polyclinic/PolyclinicContracts/BusinessLogicsContracts/IRecipeLogic.cs index e5cd24c..c2ca304 100644 --- a/Polyclinic/PolyclinicContracts/BusinessLogicsContracts/IRecipeLogic.cs +++ b/Polyclinic/PolyclinicContracts/BusinessLogicsContracts/IRecipeLogic.cs @@ -6,7 +6,7 @@ namespace PolyclinicContracts.BusinessLogicsContracts { public interface IRecipeLogic { - List? ReadList(RecipeSearchModel? model); + List? ReadList(RecipeSearchModel? model = null); RecipeViewModel? ReadElement(RecipeSearchModel model); bool Create(RecipeBindingModel model); bool Update(RecipeBindingModel model); diff --git a/Polyclinic/PolyclinicWebAppSuretor/Controllers/HomeController.cs b/Polyclinic/PolyclinicWebAppSuretor/Controllers/HomeController.cs index a2185f1..9747355 100644 --- a/Polyclinic/PolyclinicWebAppSuretor/Controllers/HomeController.cs +++ b/Polyclinic/PolyclinicWebAppSuretor/Controllers/HomeController.cs @@ -20,6 +20,7 @@ namespace PolyclinicWebAppSuretor.Controllers private readonly ISymptomLogic _symptomLogic; private readonly ICourseLogic _courseLogic; private readonly ISuretorReportLogic _suretorReportLogic; + private readonly IUserLogic _userLogic; public HomeController(ILogger logger, IProcedureLogic procedureLogic, @@ -27,7 +28,8 @@ namespace PolyclinicWebAppSuretor.Controllers IRecipeLogic recipeLogic, ISymptomLogic symptomLogic, ICourseLogic courseLogic, - ISuretorReportLogic suretorReportLogic) + ISuretorReportLogic suretorReportLogic, + IUserLogic userLogic) { _logger = logger; _procedureLogic = procedureLogic; @@ -36,6 +38,7 @@ namespace PolyclinicWebAppSuretor.Controllers _symptomLogic = symptomLogic; _courseLogic = courseLogic; _suretorReportLogic = suretorReportLogic; + _userLogic = userLogic; } public IActionResult Index() @@ -48,6 +51,36 @@ namespace PolyclinicWebAppSuretor.Controllers return View(); } + [HttpGet] + [HttpPost] + public IActionResult Register(RegisterModel model) + { + var errors = new List(); + + 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(); + } + } + /// /// RECIPES /// @@ -73,7 +106,7 @@ namespace PolyclinicWebAppSuretor.Controllers ViewData["Title"] = " "; model = new() { - Procedures = _procedureLogic.ReadList(null).Select(x => (x, false)).ToList() + Procedures = _procedureLogic.ReadList().Select(x => (x, false)).ToList() }; return View("CreateRecipe", model); } @@ -89,7 +122,7 @@ namespace PolyclinicWebAppSuretor.Controllers RecipeProcedures = selectedProcedures .ToDictionary( 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] public IActionResult EditRecipe(int id, RecipeModel model, int[] selectedProcedures) { + ViewBag.Courses = _courseLogic.ReadList(); + if (HttpContext.Request.Method == "GET") { 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() + Procedures = _procedureLogic.ReadList().Select(x => (x, obj.RecipeProcedures.ContainsKey(x.Id))).ToList() }; - ViewData["Title"] = " "; + ViewData["Title"] = " "; return View("CreateRecipe", model); } else @@ -125,7 +160,7 @@ namespace PolyclinicWebAppSuretor.Controllers RecipeProcedures = selectedProcedures .ToDictionary( x => x, - x => allProcedures.First(y => y.Id == x) as IProcedureModel + x => allProcedures.Where(y => y.Id == x) as IProcedureModel ) }; _recipeLogic.Update(recipe); @@ -314,12 +349,12 @@ namespace PolyclinicWebAppSuretor.Controllers [HttpPost] public IActionResult CreateWordFile(int procedureId, string fileName, string fileFormat) { - var procedure = _procedureLogic.ReadElement(new ProcedureSearchModel { Id = procedureId}); + var procedure = _procedureLogic.ReadElement(new ProcedureSearchModel { Id = procedureId }); ViewBag.Procedures = procedure; fileName = fileName + $".{fileFormat}"; - if(procedure == null) + if (procedure == null) { return NotFound(" "); } @@ -329,11 +364,11 @@ namespace PolyclinicWebAppSuretor.Controllers FileName = fileName, }; - var procedureSearch = new ProcedureSearchModel { Id = procedureId}; + var procedureSearch = new ProcedureSearchModel { Id = procedureId }; if (fileFormat == "docx") { - _suretorReportLogic.SaveCoursesByProcedureToWordFile(report,procedureSearch); + _suretorReportLogic.SaveCoursesByProcedureToWordFile(report, procedureSearch); } var filePath = Path.Combine(Directory.GetCurrentDirectory(), fileName); @@ -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)] public IActionResult Error() { diff --git a/Polyclinic/PolyclinicWebAppSuretor/Program.cs b/Polyclinic/PolyclinicWebAppSuretor/Program.cs index 86ff5bf..565fc18 100644 --- a/Polyclinic/PolyclinicWebAppSuretor/Program.cs +++ b/Polyclinic/PolyclinicWebAppSuretor/Program.cs @@ -14,10 +14,12 @@ builder.Logging.AddLog4Net("log4net.config"); builder.Services.AddTransient(); builder.Services.AddTransient(); builder.Services.AddTransient(); +builder.Services.AddTransient(); builder.Services.AddTransient(); builder.Services.AddTransient(); builder.Services.AddTransient(); +builder.Services.AddTransient(); builder.Services.AddTransient(); builder.Services.AddTransient(); diff --git a/Polyclinic/PolyclinicWebAppSuretor/Views/Home/CreateRecipe.cshtml b/Polyclinic/PolyclinicWebAppSuretor/Views/Home/CreateRecipe.cshtml index 8155796..54ce593 100644 --- a/Polyclinic/PolyclinicWebAppSuretor/Views/Home/CreateRecipe.cshtml +++ b/Polyclinic/PolyclinicWebAppSuretor/Views/Home/CreateRecipe.cshtml @@ -1,5 +1,6 @@ @using PolyclinicContracts.ViewModels @model RecipeModel +

@ViewData["Title"]

@ViewData["Title"]

diff --git a/Polyclinic/PolyclinicWebAppSuretor/Views/Home/Register.cshtml b/Polyclinic/PolyclinicWebAppSuretor/Views/Home/Register.cshtml index 21c8dbb..690c931 100644 --- a/Polyclinic/PolyclinicWebAppSuretor/Views/Home/Register.cshtml +++ b/Polyclinic/PolyclinicWebAppSuretor/Views/Home/Register.cshtml @@ -1,6 +1,5 @@ -@{ - ViewBag.SelectedSiteMenuItem = SiteMenuItems.Register; -} +@model RegisterModel +

Регистрация

@@ -8,19 +7,25 @@ - +
- +
- + +
+
+ +