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)