From 7d8ea70e32e86990b606794cbd3f955913f3d12b Mon Sep 17 00:00:00 2001 From: gg12 darfren Date: Sat, 27 Apr 2024 11:28:45 +0400 Subject: [PATCH 1/6] =?UTF-8?q?=D0=B6=D0=B4=D1=83=20=D0=BA=D0=BE=D0=BD?= =?UTF-8?q?=D1=82=D1=80=D0=BE=D0=BB=D0=BB=D0=B5=D1=80=20=D0=B6=D0=B8=D0=B2?= =?UTF-8?q?=D0=BE=D1=82=D0=BD=D0=BE=D0=B3=D0=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/HomeController.cs | 24 +++++++++++--- .../Views/Home/CreateMedicine.cshtml | 11 +++++++ .../Views/Home/UpdateMedicine.cshtml | 33 ++++++++++--------- 3 files changed, 49 insertions(+), 19 deletions(-) diff --git a/VetClinic/PharmacistApp/Controllers/HomeController.cs b/VetClinic/PharmacistApp/Controllers/HomeController.cs index 1f6273d..0edecba 100644 --- a/VetClinic/PharmacistApp/Controllers/HomeController.cs +++ b/VetClinic/PharmacistApp/Controllers/HomeController.cs @@ -2,6 +2,7 @@ using Microsoft.AspNetCore.Mvc; using PharmacistApp.Models; using System.Diagnostics; using VetClinicContracts.BindingModels; +using VetClinicContracts.SearchModels; using VetClinicContracts.ViewModels; using VetClinicDataBaseImplement.Models; using VetClinicDataModels.Models; @@ -116,13 +117,15 @@ View(APIPharmacist.GetRequest>($"api/medicine/getmedicin { return Redirect("~/Home/Enter"); } + ViewBag.Animals = APIPharmacist.GetRequest>($"api/animal/getanimals"); + return View(); } [HttpPost] - public void CreateMedicine(string name, int price) + public void CreateMedicine(string name, int price, List animals) { if (APIPharmacist.Pharmacist == null) { @@ -132,11 +135,18 @@ View(APIPharmacist.GetRequest>($"api/medicine/getmedicin { throw new Exception("Ошибка в введенных данных"); } + Dictionary a = new Dictionary(); + foreach (int animal in animals) + { + a.Add(animal, new AnimalSearchModel { Id = animal } as IAnimalModel); + } + APIPharmacist.PostRequest("api/medicine/createmedicine", new MedicineBindingModel { MedicineName = name, Price = price, - PharmacistId = APIPharmacist.Pharmacist.Id + PharmacistId = APIPharmacist.Pharmacist.Id, + MedicineAnimals = a }) ; Response.Redirect("Index"); } @@ -172,12 +182,13 @@ View(APIPharmacist.GetRequest>($"api/medicine/getmedicin return Redirect("~/Home/Enter"); } ViewBag.Medicines = APIPharmacist.GetRequest>($"api/medicine/getmedicines?pharmacistid={APIPharmacist.Pharmacist.Id}"); + ViewBag.Animals = APIPharmacist.GetRequest>($"api/animal/getanimals"); return View(); } [HttpPost] public void UpdateMedicine(int medicine, string name, int price, - Dictionary medicineAnimals = null) + List animals) { if (APIPharmacist.Pharmacist == null) { @@ -187,13 +198,18 @@ View(APIPharmacist.GetRequest>($"api/medicine/getmedicin { throw new Exception("Ошибка в введенных данных"); } + Dictionary a = new Dictionary(); + foreach (int animal in animals) + { + a.Add(animal, new AnimalSearchModel { Id = animal } as IAnimalModel); + } APIPharmacist.PostRequest("api/medicine/updatemedicine", new MedicineBindingModel { Id = medicine, MedicineName = name, Price = price, PharmacistId = APIPharmacist.Pharmacist.Id, - MedicineAnimals = medicineAnimals + MedicineAnimals = a }); Response.Redirect("Index"); } diff --git a/VetClinic/PharmacistApp/Views/Home/CreateMedicine.cshtml b/VetClinic/PharmacistApp/Views/Home/CreateMedicine.cshtml index 9a31add..29a5a91 100644 --- a/VetClinic/PharmacistApp/Views/Home/CreateMedicine.cshtml +++ b/VetClinic/PharmacistApp/Views/Home/CreateMedicine.cshtml @@ -18,6 +18,17 @@ +
+
Животные:
+
+ +
+
diff --git a/VetClinic/PharmacistApp/Views/Home/UpdateMedicine.cshtml b/VetClinic/PharmacistApp/Views/Home/UpdateMedicine.cshtml index b389ecb..8f327cf 100644 --- a/VetClinic/PharmacistApp/Views/Home/UpdateMedicine.cshtml +++ b/VetClinic/PharmacistApp/Views/Home/UpdateMedicine.cshtml @@ -25,21 +25,16 @@
Цена:
- - - - - - - - - -
- Животное -
-
-
+
Животные:
+
+ +
@@ -56,7 +51,15 @@ success: function (result) { $('#name').val(result.item1.medicineName); $('#price').val(result.item1.price); - $('#table-elements').html(result.item2); + $('#animals-elements').html + @foreach (var animal in ViewBag.Animals) + { + $($"#select option[value={animal.Id}]").prop('selected', false); + } + @foreach (var animal in result.Item2) + { + $($"#select option[value={animal.id}]").prop('selected', true); + } } }); }; From 8003d8f7f904f85c66218f9a83fdc50a3f0d9d07 Mon Sep 17 00:00:00 2001 From: gg12 darfren Date: Sat, 27 Apr 2024 15:06:33 +0400 Subject: [PATCH 2/6] =?UTF-8?q?=D0=B2=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82?= =?UTF-8?q?=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PharmacistApp/Controllers/HomeController.cs | 4 ++-- VetClinic/PharmacistApp/Program.cs | 2 +- .../Views/Home/UpdateMedicine.cshtml | 17 ++++++++--------- .../Models/Medicine.cs | 1 + .../VetClinicDatabase .cs | 2 +- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/VetClinic/PharmacistApp/Controllers/HomeController.cs b/VetClinic/PharmacistApp/Controllers/HomeController.cs index 0edecba..cc042bc 100644 --- a/VetClinic/PharmacistApp/Controllers/HomeController.cs +++ b/VetClinic/PharmacistApp/Controllers/HomeController.cs @@ -117,7 +117,7 @@ View(APIPharmacist.GetRequest>($"api/medicine/getmedicin { return Redirect("~/Home/Enter"); } - ViewBag.Animals = APIPharmacist.GetRequest>($"api/animal/getanimals"); + ViewBag.Animals = APIPharmacist.GetRequest>($"api/animal/getanimallist"); return View(); } @@ -182,7 +182,7 @@ View(APIPharmacist.GetRequest>($"api/medicine/getmedicin return Redirect("~/Home/Enter"); } ViewBag.Medicines = APIPharmacist.GetRequest>($"api/medicine/getmedicines?pharmacistid={APIPharmacist.Pharmacist.Id}"); - ViewBag.Animals = APIPharmacist.GetRequest>($"api/animal/getanimals"); + ViewBag.Animals = APIPharmacist.GetRequest>($"api/animal/getanimallist"); return View(); } diff --git a/VetClinic/PharmacistApp/Program.cs b/VetClinic/PharmacistApp/Program.cs index 934998a..57900d3 100644 --- a/VetClinic/PharmacistApp/Program.cs +++ b/VetClinic/PharmacistApp/Program.cs @@ -7,7 +7,7 @@ builder.Services.AddControllersWithViews(); var app = builder.Build(); -APIAdmin.Connect(builder.Configuration); +APIPharmacist.Connect(builder.Configuration); // Configure the HTTP request pipeline. if (!app.Environment.IsDevelopment()) { diff --git a/VetClinic/PharmacistApp/Views/Home/UpdateMedicine.cshtml b/VetClinic/PharmacistApp/Views/Home/UpdateMedicine.cshtml index 8f327cf..c9d851a 100644 --- a/VetClinic/PharmacistApp/Views/Home/UpdateMedicine.cshtml +++ b/VetClinic/PharmacistApp/Views/Home/UpdateMedicine.cshtml @@ -51,15 +51,14 @@ success: function (result) { $('#name').val(result.item1.medicineName); $('#price').val(result.item1.price); - $('#animals-elements').html - @foreach (var animal in ViewBag.Animals) - { - $($"#select option[value={animal.Id}]").prop('selected', false); - } - @foreach (var animal in result.Item2) - { - $($"#select option[value={animal.id}]").prop('selected', true); - } + // @foreach (var animal in ViewBag.Animals) + // { + // $($"#select option[value={animal.Id}]").prop('selected', false); + // } + // @foreach (var animal in result.Item2) + // { + // $($"#select option[value={animal.id}]").prop('selected', true); + // } } }); }; diff --git a/VetClinic/VetClinicDataBaseImplement/Models/Medicine.cs b/VetClinic/VetClinicDataBaseImplement/Models/Medicine.cs index 9861078..acc693e 100644 --- a/VetClinic/VetClinicDataBaseImplement/Models/Medicine.cs +++ b/VetClinic/VetClinicDataBaseImplement/Models/Medicine.cs @@ -54,6 +54,7 @@ namespace VetClinicDataBaseImplement.Models { Animal = context.Animals.First(y => y.Id == x.Key), }).ToList(), + PharmacistId = model.PharmacistId, Pharmacist = context.Pharmacists.First(x => x.Id == model.PharmacistId) }; } 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); } From 1ff125d5a97498c05d340403aec4a6874f22a2aa Mon Sep 17 00:00:00 2001 From: gg12 darfren Date: Sat, 27 Apr 2024 16:34:03 +0400 Subject: [PATCH 3/6] =?UTF-8?q?=D0=A1=D0=B4=D0=B5=D0=BB=D0=B0=D0=BB=20?= =?UTF-8?q?=D0=BF=D0=BE=D0=BB=D0=BD=D1=8B=D0=B9=20=D0=BA=D1=80=D1=83=D0=B4?= =?UTF-8?q?=20=D0=B4=D0=BB=D1=8F=20=D0=BC=D0=B5=D0=B4=D0=B8=D0=BA=D0=B0?= =?UTF-8?q?=D0=BC=D0=B5=D0=BD=D1=82=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PharmacistApp/Controllers/HomeController.cs | 1 - VetClinic/PharmacistApp/PharmacistApp.csproj | 2 +- .../Views/Home/UpdateMedicine.cshtml | 15 ++++----------- .../BindingModels/AnimalBindingModel.cs | 2 +- .../ViewModels/MedicineViewModel.cs | 2 -- .../Implements/MedicineStorage.cs | 2 -- .../VetClinicDataBaseImplement/Models/Medicine.cs | 1 - .../Controllers/MedicineController.cs | 12 ++++++++---- 8 files changed, 14 insertions(+), 23 deletions(-) diff --git a/VetClinic/PharmacistApp/Controllers/HomeController.cs b/VetClinic/PharmacistApp/Controllers/HomeController.cs index cc042bc..85468fe 100644 --- a/VetClinic/PharmacistApp/Controllers/HomeController.cs +++ b/VetClinic/PharmacistApp/Controllers/HomeController.cs @@ -233,7 +233,6 @@ View(APIPharmacist.GetRequest>($"api/medicine/getmedicin return default; } string table = ""; - result.Item1.MedicineAnimals.Clear(); for (int i = 0; i < result.Item2.Count; i++) { var animal = result.Item2[i]; diff --git a/VetClinic/PharmacistApp/PharmacistApp.csproj b/VetClinic/PharmacistApp/PharmacistApp.csproj index fbf47ba..5a850dc 100644 --- a/VetClinic/PharmacistApp/PharmacistApp.csproj +++ b/VetClinic/PharmacistApp/PharmacistApp.csproj @@ -16,7 +16,7 @@ - + diff --git a/VetClinic/PharmacistApp/Views/Home/UpdateMedicine.cshtml b/VetClinic/PharmacistApp/Views/Home/UpdateMedicine.cshtml index c9d851a..6c5a1b0 100644 --- a/VetClinic/PharmacistApp/Views/Home/UpdateMedicine.cshtml +++ b/VetClinic/PharmacistApp/Views/Home/UpdateMedicine.cshtml @@ -13,9 +13,6 @@
-
- -
Название:
@@ -36,6 +33,10 @@
+
+
+
+
@section Scripts @@ -51,14 +52,6 @@ success: function (result) { $('#name').val(result.item1.medicineName); $('#price').val(result.item1.price); - // @foreach (var animal in ViewBag.Animals) - // { - // $($"#select option[value={animal.Id}]").prop('selected', false); - // } - // @foreach (var animal in result.Item2) - // { - // $($"#select option[value={animal.id}]").prop('selected', true); - // } } }); }; diff --git a/VetClinic/VetClinicContracts/BindingModels/AnimalBindingModel.cs b/VetClinic/VetClinicContracts/BindingModels/AnimalBindingModel.cs index e7e48eb..b005b41 100644 --- a/VetClinic/VetClinicContracts/BindingModels/AnimalBindingModel.cs +++ b/VetClinic/VetClinicContracts/BindingModels/AnimalBindingModel.cs @@ -7,7 +7,7 @@ using VetClinicDataModels.Models; namespace VetClinicContracts.BindingModels { - public class AnimalBindingModel + public class AnimalBindingModel : IAnimalModel { public int Id { get; set; } public int AdminId { get; set; } diff --git a/VetClinic/VetClinicContracts/ViewModels/MedicineViewModel.cs b/VetClinic/VetClinicContracts/ViewModels/MedicineViewModel.cs index d7c56f8..db7c8c4 100644 --- a/VetClinic/VetClinicContracts/ViewModels/MedicineViewModel.cs +++ b/VetClinic/VetClinicContracts/ViewModels/MedicineViewModel.cs @@ -15,8 +15,6 @@ namespace VetClinicContracts.ViewModels public string MedicineName { get; set; } = string.Empty; [DisplayName("Цена медикамента")] public double Price { get; set; } - [DisplayName("Фармацевт")] - public string PharmacistFIO { get; set; } = string.Empty; public int PharmacistId { get; set; } public Dictionary MedicineAnimals { get; set; } = new(); } diff --git a/VetClinic/VetClinicDataBaseImplement/Implements/MedicineStorage.cs b/VetClinic/VetClinicDataBaseImplement/Implements/MedicineStorage.cs index b0c5092..4b8b2d7 100644 --- a/VetClinic/VetClinicDataBaseImplement/Implements/MedicineStorage.cs +++ b/VetClinic/VetClinicDataBaseImplement/Implements/MedicineStorage.cs @@ -19,7 +19,6 @@ namespace VetClinicDataBaseImplement.Implements using var context = new VetClinicDatabase(); return context.Medicines.Include(x => x.Pharmacist).Include(x => x.Animals) .ThenInclude(x => x.Animal) - .ToList() .Select(x => x.GetViewModel) .ToList(); } @@ -30,7 +29,6 @@ namespace VetClinicDataBaseImplement.Implements .ThenInclude(x => x.Animal) .Where(x => (string.IsNullOrEmpty(model.MedicineName) || x.MedicineName.Contains(model.MedicineName)) && (!model.PharmacistId.HasValue || x.PharmacistId == model.PharmacistId)) - .ToList() .Select(x => x.GetViewModel) .ToList(); } diff --git a/VetClinic/VetClinicDataBaseImplement/Models/Medicine.cs b/VetClinic/VetClinicDataBaseImplement/Models/Medicine.cs index acc693e..5cc4e34 100644 --- a/VetClinic/VetClinicDataBaseImplement/Models/Medicine.cs +++ b/VetClinic/VetClinicDataBaseImplement/Models/Medicine.cs @@ -69,7 +69,6 @@ namespace VetClinicDataBaseImplement.Models MedicineName = MedicineName, Price = Price, MedicineAnimals = MedicineAnimals, - PharmacistFIO = Pharmacist.PharmacistFIO }; public void UpdateAnimals(VetClinicDatabase context, MedicineBindingModel model) diff --git a/VetClinic/VetClinicRestApi/Controllers/MedicineController.cs b/VetClinic/VetClinicRestApi/Controllers/MedicineController.cs index 7a6819b..ee75164 100644 --- a/VetClinic/VetClinicRestApi/Controllers/MedicineController.cs +++ b/VetClinic/VetClinicRestApi/Controllers/MedicineController.cs @@ -27,7 +27,9 @@ namespace VetClinicRestApi.Controllers var elem = _medicine.ReadElement(new MedicineSearchModel { Id = medicineId }); if (elem == null) return null; - return Tuple.Create(elem, elem.MedicineAnimals.Select(x => x.Value.AnimalName).ToList()); + var res = Tuple.Create(elem, elem.MedicineAnimals.Select(x => x.Value.AnimalName).ToList()); + res.Item1.MedicineAnimals = null; + return res; } catch (Exception ex) { @@ -36,11 +38,14 @@ namespace VetClinicRestApi.Controllers } } [HttpGet] - public List GetMedicines(int pharmacistId) + public List? GetMedicines(int pharmacistId) { try { - return _medicine.ReadList(new MedicineSearchModel { PharmacistId = pharmacistId}); + var res = _medicine.ReadList(new MedicineSearchModel { PharmacistId = pharmacistId }); + foreach (var medicine in res) + medicine.MedicineAnimals = null; + return res; } catch (Exception ex) { @@ -67,7 +72,6 @@ namespace VetClinicRestApi.Controllers { try { - model.MedicineAnimals = null!; return _medicine.Update(model); } catch (Exception ex) From ea42dc9fc4179f4aae0493e0b40983b727d7adba Mon Sep 17 00:00:00 2001 From: gg12 darfren Date: Sat, 27 Apr 2024 17:03:13 +0400 Subject: [PATCH 4/6] =?UTF-8?q?=D0=91=D0=90=D0=93=D0=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/HomeController.cs | 30 +++++++++++++++---- .../Views/Home/UpdateMedicine.cshtml | 2 +- .../Models/Medicine.cs | 2 +- 3 files changed, 26 insertions(+), 8 deletions(-) diff --git a/VetClinic/PharmacistApp/Controllers/HomeController.cs b/VetClinic/PharmacistApp/Controllers/HomeController.cs index 85468fe..96b8910 100644 --- a/VetClinic/PharmacistApp/Controllers/HomeController.cs +++ b/VetClinic/PharmacistApp/Controllers/HomeController.cs @@ -125,13 +125,22 @@ View(APIPharmacist.GetRequest>($"api/medicine/getmedicin [HttpPost] - public void CreateMedicine(string name, int price, List animals) + public void CreateMedicine(string name, string price, List animals) { if (APIPharmacist.Pharmacist == null) { throw new Exception("Вы как сюда попали? Сюда вход только авторизованным"); } - if (string.IsNullOrEmpty(name) || price <= 0) + double _price; + try + { + _price = Convert.ToDouble(price); + } + catch(Exception ex) + { + throw new Exception("Ошибка в введенных данных"); + } + if (string.IsNullOrEmpty(name) || _price <= 0) { throw new Exception("Ошибка в введенных данных"); } @@ -144,7 +153,7 @@ View(APIPharmacist.GetRequest>($"api/medicine/getmedicin APIPharmacist.PostRequest("api/medicine/createmedicine", new MedicineBindingModel { MedicineName = name, - Price = price, + Price = Math.Round(_price, 2), PharmacistId = APIPharmacist.Pharmacist.Id, MedicineAnimals = a }) ; @@ -187,14 +196,23 @@ View(APIPharmacist.GetRequest>($"api/medicine/getmedicin } [HttpPost] - public void UpdateMedicine(int medicine, string name, int price, + public void UpdateMedicine(int medicine, string name, string price, List animals) { if (APIPharmacist.Pharmacist == null) { throw new Exception("Вы как сюда попали? Сюда вход только авторизованным"); } - if (string.IsNullOrEmpty(name) || price <= 0) + double _price; + try + { + _price = Convert.ToDouble(price); + } + catch (Exception ex) + { + throw new Exception("Ошибка в введенных данных"); + } + if (string.IsNullOrEmpty(name) || _price <= 0) { throw new Exception("Ошибка в введенных данных"); } @@ -207,7 +225,7 @@ View(APIPharmacist.GetRequest>($"api/medicine/getmedicin { Id = medicine, MedicineName = name, - Price = price, + Price = Math.Round(_price, 2), PharmacistId = APIPharmacist.Pharmacist.Id, MedicineAnimals = a }); diff --git a/VetClinic/PharmacistApp/Views/Home/UpdateMedicine.cshtml b/VetClinic/PharmacistApp/Views/Home/UpdateMedicine.cshtml index 6c5a1b0..eb1724a 100644 --- a/VetClinic/PharmacistApp/Views/Home/UpdateMedicine.cshtml +++ b/VetClinic/PharmacistApp/Views/Home/UpdateMedicine.cshtml @@ -20,7 +20,7 @@
Цена:
-
+
Животные:
diff --git a/VetClinic/VetClinicDataBaseImplement/Models/Medicine.cs b/VetClinic/VetClinicDataBaseImplement/Models/Medicine.cs index 5cc4e34..88b9b6f 100644 --- a/VetClinic/VetClinicDataBaseImplement/Models/Medicine.cs +++ b/VetClinic/VetClinicDataBaseImplement/Models/Medicine.cs @@ -80,7 +80,7 @@ namespace VetClinicDataBaseImplement.Models if (medicineAnimals != null && medicineAnimals.Count > 0) { context.MedicineAnimals.RemoveRange(medicineAnimals.Where(rec -=> !model.MedicineAnimals.ContainsKey(rec.AnimalId))); +=> !model.MedicineAnimals.ContainsKey(rec.MedicineId))); context.SaveChanges(); } From f6c25cf968e44d8c34ae1b77663ea59b805f7577 Mon Sep 17 00:00:00 2001 From: gg12 darfren Date: Sat, 27 Apr 2024 17:27:47 +0400 Subject: [PATCH 5/6] =?UTF-8?q?=D1=84=D0=B8=D0=BA=D1=88=D1=83=20=D0=B1?= =?UTF-8?q?=D0=B0=D0=B3=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- VetClinic/VetClinicDataBaseImplement/Models/Medicine.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/VetClinic/VetClinicDataBaseImplement/Models/Medicine.cs b/VetClinic/VetClinicDataBaseImplement/Models/Medicine.cs index 88b9b6f..8700680 100644 --- a/VetClinic/VetClinicDataBaseImplement/Models/Medicine.cs +++ b/VetClinic/VetClinicDataBaseImplement/Models/Medicine.cs @@ -80,8 +80,11 @@ namespace VetClinicDataBaseImplement.Models if (medicineAnimals != null && medicineAnimals.Count > 0) { context.MedicineAnimals.RemoveRange(medicineAnimals.Where(rec -=> !model.MedicineAnimals.ContainsKey(rec.MedicineId))); - +=> !model.MedicineAnimals.ContainsKey(rec.AnimalId))); + foreach (var animal in medicineAnimals) + { + model.MedicineAnimals.Remove(animal.AnimalId); + } context.SaveChanges(); } var medicine = context.Medicines.First(x => x.Id == Id); From 7214604c6705fd48364d2fcebb70146248d5d0a8 Mon Sep 17 00:00:00 2001 From: gg12 darfren Date: Sat, 27 Apr 2024 18:51:12 +0400 Subject: [PATCH 6/6] =?UTF-8?q?=D0=A1=D0=94=D0=95=D0=9B=D0=90=D0=9B=20?= =?UTF-8?q?=D0=A1=D0=94=D0=95=D0=9B=D0=90=D0=9B=20=D0=A1=D0=94=D0=95=D0=9B?= =?UTF-8?q?=D0=90=D0=9B=20=D0=A3=D0=A0=D0=90=D0=90=D0=90=D0=90=D0=90=D0=90?= =?UTF-8?q?=D0=90=D0=90=D0=90=D0=90=D0=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PharmacistApp/Controllers/HomeController.cs | 13 +++---------- .../PharmacistApp/Views/Home/UpdateMedicine.cshtml | 11 +++++++++-- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/VetClinic/PharmacistApp/Controllers/HomeController.cs b/VetClinic/PharmacistApp/Controllers/HomeController.cs index 96b8910..68ce4cc 100644 --- a/VetClinic/PharmacistApp/Controllers/HomeController.cs +++ b/VetClinic/PharmacistApp/Controllers/HomeController.cs @@ -239,7 +239,7 @@ View(APIPharmacist.GetRequest>($"api/medicine/getmedicin } [HttpGet] - public Tuple? GetMedicine(int medicineId) + public Tuple>? GetMedicine(int medicineId) { if (APIPharmacist.Pharmacist == null) { @@ -250,15 +250,8 @@ View(APIPharmacist.GetRequest>($"api/medicine/getmedicin { return default; } - string table = ""; - for (int i = 0; i < result.Item2.Count; i++) - { - var animal = result.Item2[i]; - table += ""; - table += $"{animal}"; - table += ""; - } - return Tuple.Create(result.Item1, table); + + return result; } [HttpGet] diff --git a/VetClinic/PharmacistApp/Views/Home/UpdateMedicine.cshtml b/VetClinic/PharmacistApp/Views/Home/UpdateMedicine.cshtml index eb1724a..d1ba160 100644 --- a/VetClinic/PharmacistApp/Views/Home/UpdateMedicine.cshtml +++ b/VetClinic/PharmacistApp/Views/Home/UpdateMedicine.cshtml @@ -25,10 +25,10 @@
Животные:
- @foreach (var animal in ViewBag.Animals) { - + }
@@ -44,15 +44,22 @@