From 6cee54fb4a3887e81a7692ea9c5639812a3da2ab Mon Sep 17 00:00:00 2001 From: antoc0der <1@DESKTOP-K1L8ND3> Date: Tue, 30 Apr 2024 11:28:41 +0400 Subject: [PATCH 1/2] =?UTF-8?q?=D0=BF=D0=BE=D1=80=D1=83=D1=87=D0=B8=D1=82?= =?UTF-8?q?=D0=B5=D0=BB=D1=8C=20=D0=BE=D1=88=D0=B8=D0=B1=D0=BA=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../VeterinaryDataModels/IDrugModel.cs | 16 ---------------- .../VeterinaryDataModels/IServiceModel.cs | 17 ----------------- .../VeterinaryDataModels/Models/IDrugModel.cs | 2 +- .../Models/IServiceModel.cs | 2 +- .../Controllers/HomeController.cs | 2 +- .../Controllers/HomeController.cs | 2 ++ 6 files changed, 5 insertions(+), 36 deletions(-) delete mode 100644 VeterinaryView/VeterinaryDataModels/IDrugModel.cs delete mode 100644 VeterinaryView/VeterinaryDataModels/IServiceModel.cs diff --git a/VeterinaryView/VeterinaryDataModels/IDrugModel.cs b/VeterinaryView/VeterinaryDataModels/IDrugModel.cs deleted file mode 100644 index f41989d..0000000 --- a/VeterinaryView/VeterinaryDataModels/IDrugModel.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace VeterinaryDataModels -{ - public interface IDrugModel :IId - { - string DrugName { get; } - int Count { get; } - double Price { get; } - Dictionary DrugMedications { get; } - } -} diff --git a/VeterinaryView/VeterinaryDataModels/IServiceModel.cs b/VeterinaryView/VeterinaryDataModels/IServiceModel.cs deleted file mode 100644 index 743cb2e..0000000 --- a/VeterinaryView/VeterinaryDataModels/IServiceModel.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace VeterinaryDataModels -{ - public interface IServiceModel : IId - { - String ServiceName { get;} - int VisitId { get; } - int DoctorId { get; } - Dictionary ServiceMedications { get; } - - } -} diff --git a/VeterinaryView/VeterinaryDataModels/Models/IDrugModel.cs b/VeterinaryView/VeterinaryDataModels/Models/IDrugModel.cs index 5ba6bd0..6579c66 100644 --- a/VeterinaryView/VeterinaryDataModels/Models/IDrugModel.cs +++ b/VeterinaryView/VeterinaryDataModels/Models/IDrugModel.cs @@ -11,6 +11,6 @@ namespace VeterinaryDataModels.Models string DrugName { get; } int Count { get; } double Price { get; } - Dictionary DrugMedications { get; } + Dictionary DrugMedications { get; } } } diff --git a/VeterinaryView/VeterinaryDataModels/Models/IServiceModel.cs b/VeterinaryView/VeterinaryDataModels/Models/IServiceModel.cs index 75903a2..ac199cf 100644 --- a/VeterinaryView/VeterinaryDataModels/Models/IServiceModel.cs +++ b/VeterinaryView/VeterinaryDataModels/Models/IServiceModel.cs @@ -11,7 +11,7 @@ namespace VeterinaryDataModels.Models string ServiceName { get; } int VisitId { get; } int DoctorId { get; } - Dictionary ServiceMedications { get; } + Dictionary ServiceMedications { get; } } } diff --git a/VeterinaryView/VeterinaryShowDoctorApp/Controllers/HomeController.cs b/VeterinaryView/VeterinaryShowDoctorApp/Controllers/HomeController.cs index 4eb35bc..caec887 100644 --- a/VeterinaryView/VeterinaryShowDoctorApp/Controllers/HomeController.cs +++ b/VeterinaryView/VeterinaryShowDoctorApp/Controllers/HomeController.cs @@ -4,7 +4,7 @@ using VeterinaryShowDoctorApp.Models; using VeterinaryContracts.ViewModels; using VeterinaryContracts.BindingModels; using System.Text; -using VeterinaryDataModels; +using VeterinaryDataModels.Models; using VeterinaryContracts.SearchModels; using VeterinaryContracts.StorageContracts; diff --git a/VeterinaryView/VeterinaryShowOwnerApp/Controllers/HomeController.cs b/VeterinaryView/VeterinaryShowOwnerApp/Controllers/HomeController.cs index c994250..85489f8 100644 --- a/VeterinaryView/VeterinaryShowOwnerApp/Controllers/HomeController.cs +++ b/VeterinaryView/VeterinaryShowOwnerApp/Controllers/HomeController.cs @@ -3,6 +3,8 @@ using System.Diagnostics; using VeterinaryContracts.BindingModels; using VeterinaryContracts.ViewModels; using VeterinaryShowOwnerApp.Models; +using VeterinaryShowOwnerApp; + namespace VeterinaryShowOwnerApp.Controllers { From f57a380c664818cdda83e35368feef492c249db6 Mon Sep 17 00:00:00 2001 From: antoc0der <1@DESKTOP-K1L8ND3> Date: Tue, 30 Apr 2024 15:31:40 +0400 Subject: [PATCH 2/2] =?UTF-8?q?=D0=BF=D0=BE=D1=80=D1=83=D1=87=D0=B8=D1=82?= =?UTF-8?q?=D0=B5=D0=BB=D1=8C:=20=D0=B2=D1=81=D1=91=20=D0=BA=D1=80=D0=BE?= =?UTF-8?q?=D0=BC=D0=B5=20=D1=84=D0=BE=D1=80=D0=BC=D1=8B=20=D1=81=D0=BE?= =?UTF-8?q?=D0=B7=D0=B4=D0=B0=D0=BD=D0=B8=D1=8F=20=D1=83=D1=81=D0=BB=D1=83?= =?UTF-8?q?=D0=B3=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/HomeController.cs | 131 ++++++++++++++++-- .../Views/Home/CreateService.cshtml | 57 ++++++++ .../Views/Home/DeleteDrug.cshtml | 2 +- .../Views/Home/DeleteService.cshtml | 18 +++ .../Views/Home/Services.cshtml | 47 +++++++ .../Views/Home/UpdateService.cshtml | 66 +++++++++ 6 files changed, 307 insertions(+), 14 deletions(-) create mode 100644 VeterinaryView/VeterinaryShowDoctorApp/Views/Home/CreateService.cshtml create mode 100644 VeterinaryView/VeterinaryShowDoctorApp/Views/Home/DeleteService.cshtml create mode 100644 VeterinaryView/VeterinaryShowDoctorApp/Views/Home/Services.cshtml create mode 100644 VeterinaryView/VeterinaryShowDoctorApp/Views/Home/UpdateService.cshtml diff --git a/VeterinaryView/VeterinaryShowDoctorApp/Controllers/HomeController.cs b/VeterinaryView/VeterinaryShowDoctorApp/Controllers/HomeController.cs index caec887..e1903ed 100644 --- a/VeterinaryView/VeterinaryShowDoctorApp/Controllers/HomeController.cs +++ b/VeterinaryView/VeterinaryShowDoctorApp/Controllers/HomeController.cs @@ -83,7 +83,6 @@ namespace VeterinaryShowDoctorApp.Controllers } Response.Redirect("Index"); } - [HttpGet] public IActionResult Register() { @@ -107,7 +106,7 @@ namespace VeterinaryShowDoctorApp.Controllers Response.Redirect("Enter"); return; } - + // medications public IActionResult CreateMedication() { if (APIDoctor.Doctor == null) @@ -116,7 +115,6 @@ namespace VeterinaryShowDoctorApp.Controllers } return View(); } - [HttpPost] public void CreateMedication(string name, int price) { @@ -137,7 +135,6 @@ namespace VeterinaryShowDoctorApp.Controllers Response.Redirect("Index"); } - public IActionResult DeleteMedication() { if (APIDoctor.Doctor == null) @@ -147,7 +144,6 @@ namespace VeterinaryShowDoctorApp.Controllers ViewBag.Medications = APIDoctor.GetRequest>($"api/medication/getmedications?doctorid={APIDoctor.Doctor.Id}"); return View(); } - [HttpPost] public void DeleteMedication(int medication) { @@ -161,7 +157,6 @@ namespace VeterinaryShowDoctorApp.Controllers }); Response.Redirect("Index"); } - public IActionResult UpdateMedication() { if (APIDoctor.Doctor == null) @@ -171,7 +166,6 @@ namespace VeterinaryShowDoctorApp.Controllers ViewBag.Medications = APIDoctor.GetRequest>($"api/medication/getmedications?doctorid={APIDoctor.Doctor.Id}"); return View(); } - [HttpPost] public void UpdateMedication(int medication, string name, int price) { @@ -192,8 +186,7 @@ namespace VeterinaryShowDoctorApp.Controllers }); Response.Redirect("Index"); } - - + // drugs public IActionResult Drugs() { if (APIDoctor.Doctor == null) @@ -204,7 +197,6 @@ namespace VeterinaryShowDoctorApp.Controllers } - public IActionResult CreateDrug() { if (APIDoctor.Doctor == null) @@ -216,8 +208,6 @@ namespace VeterinaryShowDoctorApp.Controllers return View(); } - - [HttpPost] public void CreateDrug(string name, List medications, int count) { @@ -332,8 +322,123 @@ namespace VeterinaryShowDoctorApp.Controllers return result; } + // services + public IActionResult Services() + { + if (APIDoctor.Doctor == null) + { + return Redirect("~/Home/Enter"); + } + return View(APIDoctor.GetRequest>($"api/service/getservices?doctorid={APIDoctor.Doctor.Id}")); - + } + public IActionResult CreateService() + { + if (APIDoctor.Doctor == null) + { + return Redirect("~/Home/Enter"); + } + ViewBag.Medications = APIDoctor.GetRequest>($"api/medication/getmedications"); + + return View(); + } + [HttpPost] + public void CreateService(string name, List medications, int visit) + { + if (APIDoctor.Doctor == null) + { + throw new Exception("Вы как суда попали? Суда вход только авторизованным"); + } + if (string.IsNullOrEmpty(name)) + { + throw new Exception("Ошибка в введенных данных"); + } + Dictionary a = new Dictionary(); + foreach (int medication in medications) + { + a.Add(medication, new MedicationSearchModel { Id = medication } as IMedicationModel); + } + + APIDoctor.PostRequest("api/service/createservice", new ServiceBindingModel + { + ServiceName = name, + ServiceMedications = a, + VisitId = visit + }); + Response.Redirect("Index"); + } + public IActionResult DeleteService() + { + if (APIDoctor.Doctor == null) + { + return Redirect("~/Home/Enter"); + } + ViewBag.Services = APIDoctor.GetRequest>($"api/service/getservices?doctorid={APIDoctor.Doctor.Id}"); + return View(); + } + [HttpPost] + public void DeleteService(int service) + { + if (APIDoctor.Doctor == null) + { + throw new Exception("Вы как суда попали? Суда вход только авторизованным"); + } + APIDoctor.PostRequest("api/service/deleteservice", new ServiceBindingModel + { + Id = service + }); + Response.Redirect("Index"); + } + public IActionResult UpdateService() + { + if (APIDoctor.Doctor == null) + { + return Redirect("~/Home/Enter"); + } + ViewBag.Services = APIDoctor.GetRequest>($"api/drug/getservices?doctorid={APIDoctor.Doctor.Id}"); + ViewBag.Medications = APIDoctor.GetRequest>($"api/medication/getmedications"); + return View(); + } + // возможно нужно прописать визит айди + [HttpPost] + public void UpdateService(int service, string name, List medications) + { + if (APIDoctor.Doctor == null) + { + throw new Exception("Вы как суда попали? Суда вход только авторизованным"); + } + if (string.IsNullOrEmpty(name)) + { + throw new Exception("Ошибка в введенных данных"); + } + Dictionary a = new Dictionary(); + foreach (int medication in medications) + { + a.Add(medication, new MedicationSearchModel { Id = medication } as IMedicationModel); + } + APIDoctor.PostRequest("api/drug/updateservice", new ServiceBindingModel + { + Id = service, + ServiceName = name, + ServiceMedications = a + }); + Response.Redirect("Index"); + } + [HttpGet] + public Tuple>? GetService(int serviceId) + { + if (APIDoctor.Doctor == null) + { + throw new Exception("Вы как суда попали? Суда вход только авторизованным"); + } + var result = APIDoctor.GetRequest>>($"api/service/getservice?serviceid={serviceId}"); + if (result == null) + { + return default; + } + + return result; + } [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] public IActionResult Error() diff --git a/VeterinaryView/VeterinaryShowDoctorApp/Views/Home/CreateService.cshtml b/VeterinaryView/VeterinaryShowDoctorApp/Views/Home/CreateService.cshtml new file mode 100644 index 0000000..fe851f4 --- /dev/null +++ b/VeterinaryView/VeterinaryShowDoctorApp/Views/Home/CreateService.cshtml @@ -0,0 +1,57 @@ +@{ + ViewData["Title"] = "CreateService"; +} + +
+

Создание услуги

+
+
+
+
Название:
+
+ +
+
+
+
Визиты:
+
+ +
+
+
+
Медикаменты:
+
+ +
+
+
+
+
+ +
+
+
+ \ No newline at end of file diff --git a/VeterinaryView/VeterinaryShowDoctorApp/Views/Home/DeleteDrug.cshtml b/VeterinaryView/VeterinaryShowDoctorApp/Views/Home/DeleteDrug.cshtml index 109e10e..e2be5dc 100644 --- a/VeterinaryView/VeterinaryShowDoctorApp/Views/Home/DeleteDrug.cshtml +++ b/VeterinaryView/VeterinaryShowDoctorApp/Views/Home/DeleteDrug.cshtml @@ -15,4 +15,4 @@
-s + diff --git a/VeterinaryView/VeterinaryShowDoctorApp/Views/Home/DeleteService.cshtml b/VeterinaryView/VeterinaryShowDoctorApp/Views/Home/DeleteService.cshtml new file mode 100644 index 0000000..3fe80bc --- /dev/null +++ b/VeterinaryView/VeterinaryShowDoctorApp/Views/Home/DeleteService.cshtml @@ -0,0 +1,18 @@ +@{ + ViewData["Title"] = "DeleteService"; +} +
+

Удаление услуги

+
+
+
+
Услуга:
+
+ +
+
+
+
+
+
+
diff --git a/VeterinaryView/VeterinaryShowDoctorApp/Views/Home/Services.cshtml b/VeterinaryView/VeterinaryShowDoctorApp/Views/Home/Services.cshtml new file mode 100644 index 0000000..e2b2de4 --- /dev/null +++ b/VeterinaryView/VeterinaryShowDoctorApp/Views/Home/Services.cshtml @@ -0,0 +1,47 @@ +@using VeterinaryContracts.ViewModels +@model List +@{ + ViewData["Title"] = "Services"; +} +
+

Услуги

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

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

+ return; + } +

+ Создать услугу + Обновить услугу + Удалить услугу +

+ + + + + + + + + @foreach (var item in Model) + { + + + + + } + +
+ Номер + + Название +
+ @Html.DisplayFor(modelItem =>item.Id) + + @Html.DisplayFor(modelItem =>item.ServiceName) +
+ } +
diff --git a/VeterinaryView/VeterinaryShowDoctorApp/Views/Home/UpdateService.cshtml b/VeterinaryView/VeterinaryShowDoctorApp/Views/Home/UpdateService.cshtml new file mode 100644 index 0000000..209cf33 --- /dev/null +++ b/VeterinaryView/VeterinaryShowDoctorApp/Views/Home/UpdateService.cshtml @@ -0,0 +1,66 @@ +@using VeterinaryContracts.ViewModels; + +@{ + ViewData["Title"] = "UpdateService"; +} + +
+

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

+
+
+
+
Услуга:
+
+ +
+
+
+
Название:
+
+
+
+
Медикаменты:
+
+ +
+
+
+
+
+
+
+ +@section Scripts + { + +} \ No newline at end of file