From 0311309a63f2ba6c24d56f19256172cbf069c9c9 Mon Sep 17 00:00:00 2001 From: gg12 darfren Date: Mon, 29 Apr 2024 22:52:25 +0400 Subject: [PATCH] =?UTF-8?q?=D0=95=D1=89=D0=B5=20=D0=B4=D0=BE=D0=BF=D0=B8?= =?UTF-8?q?=D0=BB=D0=B8=D0=B2=D0=B0=D1=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PharmacistApp/Controllers/HomeController.cs | 4 ++-- .../VetClinicDataBaseImplement/VetClinicDatabase .cs | 2 +- .../VetClinicRestApi/Controllers/AnimalContoller.cs | 8 ++++++-- .../Controllers/MedicineController.cs | 2 +- .../VetClinicRestApi/Controllers/VisitController.cs | 12 ++++++++---- 5 files changed, 18 insertions(+), 10 deletions(-) diff --git a/VetClinic/PharmacistApp/Controllers/HomeController.cs b/VetClinic/PharmacistApp/Controllers/HomeController.cs index 79aeded..b355c26 100644 --- a/VetClinic/PharmacistApp/Controllers/HomeController.cs +++ b/VetClinic/PharmacistApp/Controllers/HomeController.cs @@ -275,7 +275,7 @@ View(APIPharmacist.GetRequest>($"api/medicine/getmedicin Dictionary a = new Dictionary(); foreach (int animal in animals) { - a.Add(animal, new AnimalBindingModel { Id = animal } as IAnimalModel); + a.Add(animal, new AnimalSearchModel { Id = animal } as IAnimalModel); } APIPharmacist.PostRequest("api/medicine/updatemedicine?isconnection=true", new MedicineBindingModel { @@ -376,7 +376,7 @@ View(APIPharmacist.GetRequest>($"api/service/getservices? Dictionary a = new Dictionary(); foreach (int medicine in medicines) { - a.Add(medicine, new MedicineBindingModel { Id = medicine } as IMedicineModel); + a.Add(medicine, new MedicineSearchModel { Id = medicine } as IMedicineModel); } APIPharmacist.PostRequest("api/service/createservice", new ServiceBindingModel diff --git a/VetClinic/VetClinicDataBaseImplement/VetClinicDatabase .cs b/VetClinic/VetClinicDataBaseImplement/VetClinicDatabase .cs index 1d9e6df..3aa2bb9 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\SQLEXPRESS02;Initial Catalog=VetClinicDatabase;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True"); + optionsBuilder.UseSqlServer(@"Data Source=localhost\SQLEXPRESS;Initial Catalog=VetClinicDatabase;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True"); } base.OnConfiguring(optionsBuilder); } diff --git a/VetClinic/VetClinicRestApi/Controllers/AnimalContoller.cs b/VetClinic/VetClinicRestApi/Controllers/AnimalContoller.cs index 3dd7b53..c4d7a59 100644 --- a/VetClinic/VetClinicRestApi/Controllers/AnimalContoller.cs +++ b/VetClinic/VetClinicRestApi/Controllers/AnimalContoller.cs @@ -40,11 +40,15 @@ namespace VetClinicRestApi.Controllers } [HttpGet] - public List? GetAnimalList(int adminId) + public List? GetAnimalList(int? adminId = null) { try { - var res = _animal.ReadList(new AnimalSearchModel { AdminId = adminId }); + List res; + if (!adminId.HasValue) + res = _animal.ReadList(null); + else + res = _animal.ReadList(new AnimalSearchModel { AdminId = adminId }); foreach (var animal in res) animal.VisitAnimals = null!; return res; diff --git a/VetClinic/VetClinicRestApi/Controllers/MedicineController.cs b/VetClinic/VetClinicRestApi/Controllers/MedicineController.cs index 452a64f..94fe345 100644 --- a/VetClinic/VetClinicRestApi/Controllers/MedicineController.cs +++ b/VetClinic/VetClinicRestApi/Controllers/MedicineController.cs @@ -49,7 +49,7 @@ namespace VetClinicRestApi.Controllers else res = _medicine.ReadList(new MedicineSearchModel { PharmacistId = pharmacistId }); foreach (var medicine in res) - medicine.MedicineAnimals = null; + medicine.MedicineAnimals = null!; return res; } catch (Exception ex) diff --git a/VetClinic/VetClinicRestApi/Controllers/VisitController.cs b/VetClinic/VetClinicRestApi/Controllers/VisitController.cs index 78dcac9..bb295a2 100644 --- a/VetClinic/VetClinicRestApi/Controllers/VisitController.cs +++ b/VetClinic/VetClinicRestApi/Controllers/VisitController.cs @@ -39,18 +39,22 @@ namespace VetClinicRestApi.Controllers } } [HttpGet] - public List GetVisits(int adminId) + public List GetVisits(int? adminId = null) { try { - var res = _visit.ReadList(new VisitSearchModel { AdminId = adminId }); + List res; + if (!adminId.HasValue) + res = _visit.ReadList(null); + else + res = _visit.ReadList(new VisitSearchModel { AdminId = adminId }); foreach (var visit in res) - visit.ServiceVisits = null; + visit.ServiceVisits = null!; return res; } catch (Exception ex) { - _logger.LogError(ex, "Ошибка получения списка животного"); + _logger.LogError(ex, "Ошибка получения списка визитов"); throw; } }