From 4eb1097562653d1f2003d2ef722405542c4ea1bc Mon Sep 17 00:00:00 2001 From: goblinrf Date: Wed, 1 May 2024 23:12:19 +0400 Subject: [PATCH] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D1=8B=20=D0=BD=D0=B5=D0=B4=D0=BE=D1=87=D1=91=D1=82?= =?UTF-8?q?=D1=8B,=20=D0=B2=D1=81=D0=B5=20=D0=BC=D0=B0=D0=BA=D0=B5=D1=82?= =?UTF-8?q?=D1=8B=20=D0=BE=D1=82=D0=BA=D1=80=D1=8B=D0=B2=D0=B0=D1=8E=D1=82?= =?UTF-8?q?=D1=81=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/HomeController.cs | 50 ++++++++++++-- .../Views/Home/Create.cshtml | 13 +++- .../VetClinicAdminApi/Views/Home/Index.cshtml | 1 - .../Views/Home/Report.cshtml | 59 +++++++++++++++++ .../Views/Home/ServiceListReport.cshtml | 30 +++++++++ .../Views/Home/ServiceVisits.cshtml | 65 ------------------- .../Views/Home/Update.cshtml | 18 ++++- .../Views/Home/UpdateAnimal.cshtml | 2 +- .../Views/Home/UpdateVaccination.cshtml | 24 ++++++- .../Views/Home/VisitAnimals.cshtml | 2 +- .../Views/Shared/_Layout.cshtml | 6 ++ .../SearchModels/VaccinationSearchModel.cs | 1 + .../Implements/VaccinationStorage.cs | 2 +- .../VetClinicDatabase .cs | 2 +- .../Controllers/VaccinationController.cs | 24 +++++-- 15 files changed, 211 insertions(+), 88 deletions(-) create mode 100644 VetClinic/VetClinicAdminApi/Views/Home/Report.cshtml create mode 100644 VetClinic/VetClinicAdminApi/Views/Home/ServiceListReport.cshtml delete mode 100644 VetClinic/VetClinicAdminApi/Views/Home/ServiceVisits.cshtml diff --git a/VetClinic/VetClinicAdminApi/Controllers/HomeController.cs b/VetClinic/VetClinicAdminApi/Controllers/HomeController.cs index 06790da..e8bf336 100644 --- a/VetClinic/VetClinicAdminApi/Controllers/HomeController.cs +++ b/VetClinic/VetClinicAdminApi/Controllers/HomeController.cs @@ -6,6 +6,7 @@ using VetClinicContracts.ViewModels; using VetClinicDataModels.Models; using System.Text; using VetClinicContracts.SearchModels; +using System.IO.Pipelines; namespace VetClinicAdminApp.Controllers @@ -18,7 +19,17 @@ namespace VetClinicAdminApp.Controllers { _logger = logger; } - + [HttpGet] + public IActionResult ServiceListReport() + { + ViewBag.Animals = APIAdmin.GetRequest>($"api/animal/getanimallist?adminid={APIAdmin.Admin.Id}"); + return View(); + } + [HttpGet] + public IActionResult Report() + { + return View(); + } public IActionResult Index() { if (APIAdmin.Admin == null) @@ -46,7 +57,7 @@ View(APIAdmin.GetRequest>($"api/animal/getanimallist?admin return Redirect("~/Home/Enter"); } return -View(APIAdmin.GetRequest>($"api/vaccination/getvaccinations?vaccinationId={APIAdmin.Admin.Id}")); +View(APIAdmin.GetRequest>($"api/vaccination/getvaccinations?adminId={APIAdmin.Admin.Id}")); } @@ -137,6 +148,7 @@ View(APIAdmin.GetRequest>($"api/vaccination/getvaccin { return Redirect("~/Home/Enter"); } + ViewBag.Services = APIAdmin.GetRequest>($"api/service/getservices"); return View(); } public IActionResult CreateAnimal() @@ -145,11 +157,12 @@ View(APIAdmin.GetRequest>($"api/vaccination/getvaccin { return Redirect("~/Home/Enter"); } + ViewBag.Services = APIAdmin.GetRequest>($"api/service/getservices?adminid={APIAdmin.Admin.Id}"); return View(); } public IActionResult CreateVaccination() { - ViewBag.Animals = APIAdmin.GetRequest>("api/animal/getanimallist"); + ViewBag.Animals = APIAdmin.GetRequest>($"api/animal/getanimallist?adminid={APIAdmin.Admin.Id}"); return View(); } @@ -192,7 +205,7 @@ View(APIAdmin.GetRequest>($"api/vaccination/getvaccin Response.Redirect("IndexAnimals"); } [HttpPost] - public void CreateVaccination(int animale, string name, double cost,DateTime date) + public void CreateVaccination(int animale, string name, string cost,DateTime date) { if (APIAdmin.Admin == null) { @@ -202,15 +215,35 @@ View(APIAdmin.GetRequest>($"api/vaccination/getvaccin { throw new Exception("Ошибка в введенных данных"); } - if (cost <= 0) + StringBuilder st = new StringBuilder(cost); + for (int i = 0; i < cost.Length; i++) + { + if (cost[i] == '.') + st[i] = ','; + } + cost = st.ToString(); + double _cost; + try + { + _cost = Convert.ToDouble(cost); + } + catch (Exception ex) + { + throw new Exception("Ошибка в введенных данных"); + } + if (_cost <= 0) { throw new Exception("Цена должна быть выше 0"); } + if (date == null) + { + throw new Exception("Выберите дату"); + } APIAdmin.PostRequest("api/vaccination/createvaccination", new VaccinationBindingModel { NameVaccination = name, AnimalId = animale, - CostVaccination = cost, + CostVaccination = Math.Round(_cost, 2), DateStamp = date }); Response.Redirect("IndexVaccinations"); @@ -292,7 +325,8 @@ View(APIAdmin.GetRequest>($"api/vaccination/getvaccin { return Redirect("~/Home/Enter"); } - ViewBag.Visits = APIAdmin.GetRequest>("api/visit/getvisits"); + ViewBag.Visits = APIAdmin.GetRequest>($"api/visit/getvisits?pharmacistid={APIAdmin.Admin.Id}"); + ViewBag.Services = APIAdmin.GetRequest>($"api/service/getservices"); return View(); } @@ -322,6 +356,7 @@ View(APIAdmin.GetRequest>($"api/vaccination/getvaccin return Redirect("~/Home/Enter"); } ViewBag.Animals = APIAdmin.GetRequest>($"api/animal/getanimallist?adminid={APIAdmin.Admin.Id}"); + return View(); } @@ -429,6 +464,7 @@ View(APIAdmin.GetRequest>($"api/vaccination/getvaccin return Redirect("~/Home/Enter"); } ViewBag.Vaccinations = APIAdmin.GetRequest>($"api/vaccination/getvaccinations?adminid={APIAdmin.Admin.Id}"); + ViewBag.Animals = APIAdmin.GetRequest>($"api/animal/getanimallist?adminid={APIAdmin.Admin.Id}"); return View(); } diff --git a/VetClinic/VetClinicAdminApi/Views/Home/Create.cshtml b/VetClinic/VetClinicAdminApi/Views/Home/Create.cshtml index d23f844..2f2a5b5 100644 --- a/VetClinic/VetClinicAdminApi/Views/Home/Create.cshtml +++ b/VetClinic/VetClinicAdminApi/Views/Home/Create.cshtml @@ -16,7 +16,18 @@
Дата:
- + +
+
+
+
Услуги:
+
+
diff --git a/VetClinic/VetClinicAdminApi/Views/Home/Index.cshtml b/VetClinic/VetClinicAdminApi/Views/Home/Index.cshtml index 6bd63b8..bdb40a4 100644 --- a/VetClinic/VetClinicAdminApi/Views/Home/Index.cshtml +++ b/VetClinic/VetClinicAdminApi/Views/Home/Index.cshtml @@ -20,7 +20,6 @@

Редактировать визит Удалить визит - Связать визит и услуги

Создать визит diff --git a/VetClinic/VetClinicAdminApi/Views/Home/Report.cshtml b/VetClinic/VetClinicAdminApi/Views/Home/Report.cshtml new file mode 100644 index 0000000..5b3124a --- /dev/null +++ b/VetClinic/VetClinicAdminApi/Views/Home/Report.cshtml @@ -0,0 +1,59 @@ +@{ + ViewData["Title"] = "Report"; +} +

+

Список визитов с расшифровкой по медикаментам и прививкам

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

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

+ // return; + // } +
+
Начальная дата:
+
+ +
+
+
+
Конечная дата:
+
+ +
+
+ + + + + + + + + + + + будет заполняться вьюшками отчета + +
+ Номер + + Дата + + Визит + + Медикамент + + Прививка +
+
+
+
+
+
+
+
+
+ } +
\ No newline at end of file diff --git a/VetClinic/VetClinicAdminApi/Views/Home/ServiceListReport.cshtml b/VetClinic/VetClinicAdminApi/Views/Home/ServiceListReport.cshtml new file mode 100644 index 0000000..37422e1 --- /dev/null +++ b/VetClinic/VetClinicAdminApi/Views/Home/ServiceListReport.cshtml @@ -0,0 +1,30 @@ +@using VetClinicContracts.ViewModels; + +@{ + + ViewData["Title"] = "ServiceListReport"; +} + +
+

Создать списки услуг для животных

+
+ +
+ +
+
Животные:
+
+ +
+
+
+
+
+
+
+
diff --git a/VetClinic/VetClinicAdminApi/Views/Home/ServiceVisits.cshtml b/VetClinic/VetClinicAdminApi/Views/Home/ServiceVisits.cshtml deleted file mode 100644 index a26f44b..0000000 --- a/VetClinic/VetClinicAdminApi/Views/Home/ServiceVisits.cshtml +++ /dev/null @@ -1,65 +0,0 @@ -@using VetClinicContracts.ViewModels; - -@{ - ViewData["Title"] = "ServiceVisits"; -} - -
-

Связывание визита и услуги

-
-
-
-
Визит:
-
- -
-
- - -
-
Услуги:
-
- -
-
-
-
-
-
-
- -@section Scripts -{ - -} \ No newline at end of file diff --git a/VetClinic/VetClinicAdminApi/Views/Home/Update.cshtml b/VetClinic/VetClinicAdminApi/Views/Home/Update.cshtml index 9036d8d..f8241c6 100644 --- a/VetClinic/VetClinicAdminApi/Views/Home/Update.cshtml +++ b/VetClinic/VetClinicAdminApi/Views/Home/Update.cshtml @@ -22,10 +22,20 @@
Дата:
- + +
+
+
+
Услуги:
+
+
-
@@ -46,6 +56,10 @@ success: function (result) { $('#name').val(result.item1.vistName); $('#date').val(result.item1.date); + $.map(result.item2, function (n) { + console.log("#" + n); + $(`option[data-name=${n}]`).attr("selected", "selected") + }); } }); }; diff --git a/VetClinic/VetClinicAdminApi/Views/Home/UpdateAnimal.cshtml b/VetClinic/VetClinicAdminApi/Views/Home/UpdateAnimal.cshtml index 30d5dc9..0c1724f 100644 --- a/VetClinic/VetClinicAdminApi/Views/Home/UpdateAnimal.cshtml +++ b/VetClinic/VetClinicAdminApi/Views/Home/UpdateAnimal.cshtml @@ -43,7 +43,7 @@ data: { animalId: animal }, success: function (result) { $('#name').val(result.item1.animalName); - $('#family').val(result.item1.price); + $('#family').val(result.item1.family); } }); }; diff --git a/VetClinic/VetClinicAdminApi/Views/Home/UpdateVaccination.cshtml b/VetClinic/VetClinicAdminApi/Views/Home/UpdateVaccination.cshtml index e0cc10a..22d86ef 100644 --- a/VetClinic/VetClinicAdminApi/Views/Home/UpdateVaccination.cshtml +++ b/VetClinic/VetClinicAdminApi/Views/Home/UpdateVaccination.cshtml @@ -12,6 +12,17 @@
+
+
Животное:
+
+ +
+
Название:
@@ -44,13 +55,20 @@ if (snack) { $.ajax({ method: "POST", - url: "/Home/GetAnimal", - data: { animal: animal }, + url: "/Home/GetVaccination", + data: { vaccinationId: vaccinationId }, success: function (result) { - $("#animal").val(result); + $('#name').val(result.text); + $('#cost').val(result.text); + $('#date').val(result.date); + $(`option[data-name=${result.animalId}]`).attr("selected", "selected") } }); }; } + check(); + $('#vaccination').on('change', function () { + check(); + }); diff --git a/VetClinic/VetClinicAdminApi/Views/Home/VisitAnimals.cshtml b/VetClinic/VetClinicAdminApi/Views/Home/VisitAnimals.cshtml index f9d3ed4..efc05d7 100644 --- a/VetClinic/VetClinicAdminApi/Views/Home/VisitAnimals.cshtml +++ b/VetClinic/VetClinicAdminApi/Views/Home/VisitAnimals.cshtml @@ -22,7 +22,7 @@
diff --git a/VetClinic/VetClinicAdminApi/Views/Shared/_Layout.cshtml b/VetClinic/VetClinicAdminApi/Views/Shared/_Layout.cshtml index 2b2f0b6..fb46b94 100644 --- a/VetClinic/VetClinicAdminApi/Views/Shared/_Layout.cshtml +++ b/VetClinic/VetClinicAdminApi/Views/Shared/_Layout.cshtml @@ -32,6 +32,12 @@ + + diff --git a/VetClinic/VetClinicContracts/SearchModels/VaccinationSearchModel.cs b/VetClinic/VetClinicContracts/SearchModels/VaccinationSearchModel.cs index eea1372..3c3672f 100644 --- a/VetClinic/VetClinicContracts/SearchModels/VaccinationSearchModel.cs +++ b/VetClinic/VetClinicContracts/SearchModels/VaccinationSearchModel.cs @@ -9,6 +9,7 @@ namespace VetClinicContracts.SearchModels public class VaccinationSearchModel { public int? Id { get; set; } + public int? AdminId { get; set; } public string? NameVaccination { get; set; } public double? CostVaccination { get; set; } diff --git a/VetClinic/VetClinicDataBaseImplement/Implements/VaccinationStorage.cs b/VetClinic/VetClinicDataBaseImplement/Implements/VaccinationStorage.cs index bf8a591..af32289 100644 --- a/VetClinic/VetClinicDataBaseImplement/Implements/VaccinationStorage.cs +++ b/VetClinic/VetClinicDataBaseImplement/Implements/VaccinationStorage.cs @@ -25,7 +25,7 @@ namespace VetClinicDataBaseImplement.Implements using var context = new VetClinicDatabase(); return context.Vaccinations.Include(x => x.Animal).Where(x => (!model.Id.HasValue || model.Id == x.Id) && (!model.AnimalId.HasValue || model.AnimalId == x.AnimalId) && (!model.DateFrom.HasValue || model.DateFrom <= x.DateStamp) - && (!model.DateTo.HasValue || model.DateTo >= x.DateStamp)) + && (!model.DateTo.HasValue || model.DateTo >= x.DateStamp) && (!model.AdminId.HasValue || model.AdminId == x.Animal.AdminId)) .Select(x => x.GetViewModel) .ToList(); } diff --git a/VetClinic/VetClinicDataBaseImplement/VetClinicDatabase .cs b/VetClinic/VetClinicDataBaseImplement/VetClinicDatabase .cs index 3aa2bb9..1d9e6df 100644 --- a/VetClinic/VetClinicDataBaseImplement/VetClinicDatabase .cs +++ b/VetClinic/VetClinicDataBaseImplement/VetClinicDatabase .cs @@ -11,7 +11,7 @@ namespace VetClinicDataBaseImplement { if (optionsBuilder.IsConfigured == false) { - optionsBuilder.UseSqlServer(@"Data Source=localhost\SQLEXPRESS;Initial Catalog=VetClinicDatabase;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True"); + optionsBuilder.UseSqlServer(@"Data Source=localhost\SQLEXPRESS02;Initial Catalog=VetClinicDatabase;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True"); } base.OnConfiguring(optionsBuilder); } diff --git a/VetClinic/VetClinicRestApi/Controllers/VaccinationController.cs b/VetClinic/VetClinicRestApi/Controllers/VaccinationController.cs index f87ff8e..49010bc 100644 --- a/VetClinic/VetClinicRestApi/Controllers/VaccinationController.cs +++ b/VetClinic/VetClinicRestApi/Controllers/VaccinationController.cs @@ -21,22 +21,36 @@ namespace VetClinicRestApi.Controllers _logger = logger; _vaccination = vaccination; } - [HttpGet] - public List? GetVaccinations(int? animalId) + public VaccinationViewModel GetVaccination(int vaccinationId) { try { - if (!animalId.HasValue) + var elem = _vaccination.ReadElement(new VaccinationSearchModel { Id = vaccinationId }); + return elem; + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка получения прививки по id={Id}", vaccinationId); + throw; + } + } + + [HttpGet] + public List? GetVaccinations(int? adminld) + { + try + { + if (!adminld.HasValue) return _vaccination.ReadList(null); return _vaccination.ReadList(new VaccinationSearchModel { - AnimalId = animalId + AdminId = adminld }); } catch (Exception ex) { - _logger.LogError(ex, "Ошибка получения списка привиовк животного id ={ Id}", animalId); + _logger.LogError(ex, "Ошибка получения списка прививок пользователя id ={ Id}", adminld); throw; } }