From 050762b81d058ce9d7a7e875f35846fad8042556 Mon Sep 17 00:00:00 2001 From: Alenka Date: Tue, 30 Apr 2024 16:20:04 +0400 Subject: [PATCH] =?UTF-8?q?=D0=BF=D1=80=D0=BE=D0=B4=D0=BE=D0=BB=D0=B6?= =?UTF-8?q?=D0=B0=D1=8E=20=D0=B4=D0=B5=D0=BB=D0=B0=D1=82=D1=8C=20=D0=BF?= =?UTF-8?q?=D1=80=D0=B8=D0=BB=D0=BE=D0=B6=D0=B5=D0=BD=D0=B8=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/MedicineController.cs | 108 +----------------- .../HospitalRestApi/HospitalRestApi.csproj | 1 + Hospital/HospitalRestApi/Program.cs | 30 ++++- Hospital/PharmacistApp/APIPharmacist.cs | 1 + .../Controllers/HomeController.cs | 1 + Hospital/PharmacistApp/PharmacistApp.csproj | 17 +++ .../Home/CreateDescriptionProcedure.cshtml | 29 +++++ .../Views/Home/CreateProcedure.cshtml | 34 ++++++ .../Home/DeleteDescriptionProcedure.cshtml | 18 +++ .../Views/Home/DeleteProcedure.cshtml | 18 +++ .../Views/Home/DescriptionProcedure.cshtml | 53 +++++++++ .../PharmacistApp/Views/Home/Index.cshtml | 58 ++++++++++ .../Views/Home/MedicineRecipe.cshtml | 65 +++++++++++ .../PharmacistApp/Views/Home/Privacy.cshtml | 28 +++++ .../PharmacistApp/Views/Home/Procedure.cshtml | 51 +++++++++ .../PharmacistApp/Views/Home/Registr.cshtml | 48 ++++++++ .../Home/UpdateDescriptionProcedure.cshtml | 65 +++++++++++ .../Views/Home/UpdateMedicine.cshtml | 56 +++++++++ .../Views/Home/UpdateProcedure.cshtml | 71 ++++++++++++ .../Views/Shared/_ViewImports.cshtml | 3 + .../Views/Shared/_ViewStart.cshtml | 3 + 21 files changed, 649 insertions(+), 109 deletions(-) create mode 100644 Hospital/PharmacistApp/APIPharmacist.cs create mode 100644 Hospital/PharmacistApp/Controllers/HomeController.cs create mode 100644 Hospital/PharmacistApp/Views/Home/CreateDescriptionProcedure.cshtml create mode 100644 Hospital/PharmacistApp/Views/Home/CreateProcedure.cshtml create mode 100644 Hospital/PharmacistApp/Views/Home/DeleteDescriptionProcedure.cshtml create mode 100644 Hospital/PharmacistApp/Views/Home/DeleteProcedure.cshtml create mode 100644 Hospital/PharmacistApp/Views/Home/DescriptionProcedure.cshtml create mode 100644 Hospital/PharmacistApp/Views/Home/Index.cshtml create mode 100644 Hospital/PharmacistApp/Views/Home/MedicineRecipe.cshtml create mode 100644 Hospital/PharmacistApp/Views/Home/Privacy.cshtml create mode 100644 Hospital/PharmacistApp/Views/Home/Procedure.cshtml create mode 100644 Hospital/PharmacistApp/Views/Home/Registr.cshtml create mode 100644 Hospital/PharmacistApp/Views/Home/UpdateDescriptionProcedure.cshtml create mode 100644 Hospital/PharmacistApp/Views/Home/UpdateMedicine.cshtml create mode 100644 Hospital/PharmacistApp/Views/Home/UpdateProcedure.cshtml create mode 100644 Hospital/PharmacistApp/Views/Shared/_ViewImports.cshtml create mode 100644 Hospital/PharmacistApp/Views/Shared/_ViewStart.cshtml diff --git a/Hospital/HospitalRestApi/Controllers/MedicineController.cs b/Hospital/HospitalRestApi/Controllers/MedicineController.cs index 6f49b64..5f28270 100644 --- a/Hospital/HospitalRestApi/Controllers/MedicineController.cs +++ b/Hospital/HospitalRestApi/Controllers/MedicineController.cs @@ -1,107 +1 @@ -using HospitalContracts.BindingModels; -using HospitalContracts.BusinessLogicContracts; -using HospitalContracts.SearchModels; -using HospitalContracts.ViewModels; -using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Mvc; - - -using HospitalDatabaseImplement.Models; - -namespace HospitalRestApi.Controllers -{ - [Route("api/[controller]/[action]")] - [ApiController] - public class MedicineController : Controller - { - private readonly ILogger _logger; - private readonly IMedicineLogic _medicine; - public MedicineController(ILogger logger, IMedicineLogic medicine) - { - _logger = logger; - _medicine = medicine; - } - - [HttpGet] - public Tuple>? GetMedicine(int medicineId) - { - try - { - var elem = _medicine.ReadElement(new MedicineSearchModel { Id = medicineId }); - if (elem == null) - return null; - var res = Tuple.Create(elem, elem.ProcedureMedicines.Select(x => x.Value.AnimalName).ToList()); - res.Item1.MedicineAnimals = null!; - return res; - } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка получения медикамента по id={Id}", medicineId); - throw; - } - } - [HttpGet] - public List? GetMedicines(int? pharmacistId = null) - { - try - { - List res; - if (!pharmacistId.HasValue) - res = _medicine.ReadList(null); - else - res = _medicine.ReadList(new MedicineSearchModel { PharmacistId = pharmacistId }); - foreach (var medicine in res) - medicine.ProcedureMedicines = null!; - return res; - } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка получения списка медикаментов"); - throw; - } - } - [HttpPost] - public bool CreateMedicine(MedicineBindingModel model) - { - try - { - return _medicine.Create(model); - } - catch (Exception ex) - { - _logger.LogError(ex, "Не удалось создать медикамент"); - throw; - } - } - - [HttpPost] - public bool UpdateMedicine(bool isConnection, MedicineBindingModel model) - { - try - { - if (!isConnection) - model.ProcedureMedicines = null!; - return _medicine.Update(model); - } - catch (Exception ex) - { - _logger.LogError(ex, "Не удалось обновить магазин"); - throw; - } - } - - [HttpPost] - public bool DeleteMedicine(MedicineBindingModel model) - { - try - { - return _medicine.Delete(model); - } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка удаления магазина"); - throw; - } - } - } -} + \ No newline at end of file diff --git a/Hospital/HospitalRestApi/HospitalRestApi.csproj b/Hospital/HospitalRestApi/HospitalRestApi.csproj index a2bafdc..b9da3ea 100644 --- a/Hospital/HospitalRestApi/HospitalRestApi.csproj +++ b/Hospital/HospitalRestApi/HospitalRestApi.csproj @@ -12,6 +12,7 @@ + diff --git a/Hospital/HospitalRestApi/Program.cs b/Hospital/HospitalRestApi/Program.cs index 48863a6..a3f749d 100644 --- a/Hospital/HospitalRestApi/Program.cs +++ b/Hospital/HospitalRestApi/Program.cs @@ -1,19 +1,45 @@ +using HospitalBusinessLogic.BusinessLogics; +using HospitalContracts.BusinessLogicContracts; +using HospitalContracts.StoragesContracts; +using HospitalDatabaseImplement.Implements; +using Microsoft.OpenApi.Models; + var builder = WebApplication.CreateBuilder(args); +builder.Logging.SetMinimumLevel(LogLevel.Trace); +//builder.Logging.AddLog4Net("log4net.config"); + // Add services to the container. + +builder.Services.AddTransient(); + +builder.Services.AddTransient(); + + + + + +builder.Services.AddTransient(); + +builder.Services.AddTransient(); + + builder.Services.AddControllers(); // Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle builder.Services.AddEndpointsApiExplorer(); -builder.Services.AddSwaggerGen(); +builder.Services.AddSwaggerGen(c => +{ + c.SwaggerDoc("v1", new OpenApiInfo { Title = "VetClinicRestApi", Version = "v1" }); +}); var app = builder.Build(); // Configure the HTTP request pipeline. if (app.Environment.IsDevelopment()) { app.UseSwagger(); - app.UseSwaggerUI(); + app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "VetClinicRestApi v1")); } app.UseHttpsRedirection(); diff --git a/Hospital/PharmacistApp/APIPharmacist.cs b/Hospital/PharmacistApp/APIPharmacist.cs new file mode 100644 index 0000000..5f28270 --- /dev/null +++ b/Hospital/PharmacistApp/APIPharmacist.cs @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/Hospital/PharmacistApp/Controllers/HomeController.cs b/Hospital/PharmacistApp/Controllers/HomeController.cs new file mode 100644 index 0000000..5f28270 --- /dev/null +++ b/Hospital/PharmacistApp/Controllers/HomeController.cs @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/Hospital/PharmacistApp/PharmacistApp.csproj b/Hospital/PharmacistApp/PharmacistApp.csproj index c78c9c7..841d0d4 100644 --- a/Hospital/PharmacistApp/PharmacistApp.csproj +++ b/Hospital/PharmacistApp/PharmacistApp.csproj @@ -6,4 +6,21 @@ enable + + + + + + + + + + + + + + + + + diff --git a/Hospital/PharmacistApp/Views/Home/CreateDescriptionProcedure.cshtml b/Hospital/PharmacistApp/Views/Home/CreateDescriptionProcedure.cshtml new file mode 100644 index 0000000..d888227 --- /dev/null +++ b/Hospital/PharmacistApp/Views/Home/CreateDescriptionProcedure.cshtml @@ -0,0 +1,29 @@ +@{ + ViewData["Title"] = "CreateDescriptionProcedure"; +} + +
+

Создание описание к процедуре

+
+
+
+
Процедура:
+
+ +
+
+
+
Текст:
+
+ +
+
+
+
+
+ +
+
+
diff --git a/Hospital/PharmacistApp/Views/Home/CreateProcedure.cshtml b/Hospital/PharmacistApp/Views/Home/CreateProcedure.cshtml new file mode 100644 index 0000000..4280fd8 --- /dev/null +++ b/Hospital/PharmacistApp/Views/Home/CreateProcedure.cshtml @@ -0,0 +1,34 @@ +@{ + ViewData["Title"] = "CreateProcedure"; +} + +
+

Создание процедуры

+
+
+
+
Название:
+
+ +
+
+ +
+
Лекарства:
+
+ +
+
+
+
+
+ +
+
+
\ No newline at end of file diff --git a/Hospital/PharmacistApp/Views/Home/DeleteDescriptionProcedure.cshtml b/Hospital/PharmacistApp/Views/Home/DeleteDescriptionProcedure.cshtml new file mode 100644 index 0000000..1cb675d --- /dev/null +++ b/Hospital/PharmacistApp/Views/Home/DeleteDescriptionProcedure.cshtml @@ -0,0 +1,18 @@ +@{ + ViewData["Title"] = "DeleteDescriptionProcedure"; +} +
+

Удаление описания процедуры

+
+
+
+
Описание процедуры:
+
+ +
+
+
+
+
+
+
\ No newline at end of file diff --git a/Hospital/PharmacistApp/Views/Home/DeleteProcedure.cshtml b/Hospital/PharmacistApp/Views/Home/DeleteProcedure.cshtml new file mode 100644 index 0000000..a1c9bbe --- /dev/null +++ b/Hospital/PharmacistApp/Views/Home/DeleteProcedure.cshtml @@ -0,0 +1,18 @@ +@{ + ViewData["Title"] = "DeleteProcedure"; +} +
+

Удаление процедуры

+
+
+
+
Процедура:
+
+ +
+
+
+
+
+
+
s diff --git a/Hospital/PharmacistApp/Views/Home/DescriptionProcedure.cshtml b/Hospital/PharmacistApp/Views/Home/DescriptionProcedure.cshtml new file mode 100644 index 0000000..b388773 --- /dev/null +++ b/Hospital/PharmacistApp/Views/Home/DescriptionProcedure.cshtml @@ -0,0 +1,53 @@ +@using HospitalContracts.ViewModels +@model List +@{ + ViewData["Title"] = "DescriptionProcedure"; +} +
+

Описание к процедуре

+
+
+ @{ + if (Model == null) + { +

Авторизируйтесь

+ return; + } +

+ Создать описание к процедуре + Обновить описание к процедуре + Удалить описание к процедуре +

+ + + + + + + + + + + @foreach (var item in Model) + { + + + + + + + } + +
+ Номер + + Описание +
+ @Html.DisplayFor(modelItem => + item.Id) + + @Html.DisplayFor(modelItem => + item.Description) +
+ } +
\ No newline at end of file diff --git a/Hospital/PharmacistApp/Views/Home/Index.cshtml b/Hospital/PharmacistApp/Views/Home/Index.cshtml new file mode 100644 index 0000000..0a5a543 --- /dev/null +++ b/Hospital/PharmacistApp/Views/Home/Index.cshtml @@ -0,0 +1,58 @@ +@using HospitalContracts.ViewModels + +@model List +@{ + ViewData["Title"] = "Home Page"; +} +
+

Лекарства

+
+
+ @{ + if (Model == null) + { +

Авторизируйтесь

+ return; + } +

+ Создать лекарство + Обновить лекарство + Удалить лекарство + Связать лекарства и процедуры +

+ + + + + + + + + + @foreach (var item in Model) + { + + + + + + } + +
+ Номер + + Название + + Цена +
+ @Html.DisplayFor(modelItem => + item.Id) + + @Html.DisplayFor(modelItem => + item.Name) + + @Html.DisplayFor(modelItem => + item.Price) +
+ } +
\ No newline at end of file diff --git a/Hospital/PharmacistApp/Views/Home/MedicineRecipe.cshtml b/Hospital/PharmacistApp/Views/Home/MedicineRecipe.cshtml new file mode 100644 index 0000000..eb635f5 --- /dev/null +++ b/Hospital/PharmacistApp/Views/Home/MedicineRecipe.cshtml @@ -0,0 +1,65 @@ +@using HospitalContracts.ViewModels; + +@{ + ViewData["Title"] = "MedicineRecipe"; +} + +
+

Связывание лекарства и рецепта

+
+
+
+
Лекарство:
+
+ +
+
+ + +
+
Рецепт:
+
+ +
+
+
+
+
+
+
+ +@section Scripts +{ + +} \ No newline at end of file diff --git a/Hospital/PharmacistApp/Views/Home/Privacy.cshtml b/Hospital/PharmacistApp/Views/Home/Privacy.cshtml new file mode 100644 index 0000000..3cf926f --- /dev/null +++ b/Hospital/PharmacistApp/Views/Home/Privacy.cshtml @@ -0,0 +1,28 @@ +@using HospitalContracts.ViewModels + +@model PharmacistViewModel + +@{ + ViewData["Title"] = "Privacy Policy"; +} +
+

Личные данные

+
+
+
+
Login:
+
+
+
+
Пароль:
+
+
+
+
ФИО:
+
+
+
+
+
+
+
\ No newline at end of file diff --git a/Hospital/PharmacistApp/Views/Home/Procedure.cshtml b/Hospital/PharmacistApp/Views/Home/Procedure.cshtml new file mode 100644 index 0000000..8a00e93 --- /dev/null +++ b/Hospital/PharmacistApp/Views/Home/Procedure.cshtml @@ -0,0 +1,51 @@ +@using HospitalContracts.ViewModels +@model List +@{ + ViewData["Title"] = "Procedures"; +} +
+

Процедуры

+
+
+ @{ + if (Model == null) + { +

Авторизируйтесь

+ return; + } +

+ Создать процедуру + Обновить процедуру + Удалить процедуру +

+ + + + + + + + + + @foreach (var item in Model) + { + + + + + + } + +
+ Номер + + Название +
+ @Html.DisplayFor(modelItem => + item.Id) + + @Html.DisplayFor(modelItem => + item.Name) +
+ } +
\ No newline at end of file diff --git a/Hospital/PharmacistApp/Views/Home/Registr.cshtml b/Hospital/PharmacistApp/Views/Home/Registr.cshtml new file mode 100644 index 0000000..d5bf6be --- /dev/null +++ b/Hospital/PharmacistApp/Views/Home/Registr.cshtml @@ -0,0 +1,48 @@ +@{ + ViewData["Title"] = "Register"; +} + +< div class= "text-center" > + + < h2 class= "display-4" > Регистрация + +< form method = "post" > + + < div class= "row" > + + < div class= "col-4" > Email: + + < div class= "col-8" >< input type = "text" name = "email" /> + + + + < div class= "row" > + + < div class= "col-4" > Пароль: + + < div class= "col-8" >< input type = "password" name = "password" /> + + + + < div class= "row" > + + < div class= "col-4" > ФИО: + + < div class= "col-8" >< input type = "text" name = "fio" /> + + + + < div class= "row" > + + < div class= "col-8" > + + < div class= "col-4" > + + < input type = "submit" value = "Регистрация" + + class= "btn btn-primary" /> + + + + + \ No newline at end of file diff --git a/Hospital/PharmacistApp/Views/Home/UpdateDescriptionProcedure.cshtml b/Hospital/PharmacistApp/Views/Home/UpdateDescriptionProcedure.cshtml new file mode 100644 index 0000000..59dbd59 --- /dev/null +++ b/Hospital/PharmacistApp/Views/Home/UpdateDescriptionProcedure.cshtml @@ -0,0 +1,65 @@ +@{ + ViewData["Title"] = "UpdateDescriptionProcedure"; +} + +
+

Обновление описания к процедуре

+
+
+
+
Описание:
+
+ +
+
+
+
Процедура:
+
+ +
+
+
+
Текст:
+
+ +
+
+
+
+
+ +
+
+
+ \ No newline at end of file diff --git a/Hospital/PharmacistApp/Views/Home/UpdateMedicine.cshtml b/Hospital/PharmacistApp/Views/Home/UpdateMedicine.cshtml new file mode 100644 index 0000000..ce57f2f --- /dev/null +++ b/Hospital/PharmacistApp/Views/Home/UpdateMedicine.cshtml @@ -0,0 +1,56 @@ +@using HospitalContracts.ViewModels; + +@{ + ViewData["Title"] = "UpdateMedicine"; +} + +
+

Редактирование лекарства

+
+
+
+
Лекарство:
+
+ +
+
+
+
Название:
+
+
+
+
Цена:
+
+
+
+
+
+
+
+ +@section Scripts +{ + +} \ No newline at end of file diff --git a/Hospital/PharmacistApp/Views/Home/UpdateProcedure.cshtml b/Hospital/PharmacistApp/Views/Home/UpdateProcedure.cshtml new file mode 100644 index 0000000..92a5621 --- /dev/null +++ b/Hospital/PharmacistApp/Views/Home/UpdateProcedure.cshtml @@ -0,0 +1,71 @@ +@using HospitalContracts.ViewModels; + +@{ + ViewData["Title"] = "UpdateProcedure"; +} + +
+

Редактирование процедуры

+
+
+
+
Процедура:
+
+ +
+
+
+
Название:
+
+
+
+
Цена:
+
+
+
+
Лекарства:
+
+ +
+
+
+
+
+
+
+ +@section Scripts + { + +} \ No newline at end of file diff --git a/Hospital/PharmacistApp/Views/Shared/_ViewImports.cshtml b/Hospital/PharmacistApp/Views/Shared/_ViewImports.cshtml new file mode 100644 index 0000000..6bab998 --- /dev/null +++ b/Hospital/PharmacistApp/Views/Shared/_ViewImports.cshtml @@ -0,0 +1,3 @@ +@using PharmacistApp +@using PharmacistApp.Models +@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers diff --git a/Hospital/PharmacistApp/Views/Shared/_ViewStart.cshtml b/Hospital/PharmacistApp/Views/Shared/_ViewStart.cshtml new file mode 100644 index 0000000..a5f1004 --- /dev/null +++ b/Hospital/PharmacistApp/Views/Shared/_ViewStart.cshtml @@ -0,0 +1,3 @@ +@{ + Layout = "_Layout"; +}