diff --git a/VeterinaryView/VeterinaryShowDoctorApp/Controllers/HomeController.cs b/VeterinaryView/VeterinaryShowDoctorApp/Controllers/HomeController.cs index 4eb35bc..e1903ed 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; @@ -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 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 {