diff --git a/VetClinic/PharmacistApp/Controllers/HomeController.cs b/VetClinic/PharmacistApp/Controllers/HomeController.cs index b355c26..53dd0ad 100644 --- a/VetClinic/PharmacistApp/Controllers/HomeController.cs +++ b/VetClinic/PharmacistApp/Controllers/HomeController.cs @@ -490,7 +490,7 @@ View(APIPharmacist.GetRequest>($"api/service/getservices? { return Redirect("~/Home/Enter"); } - var res = APIPharmacist.GetRequest>($"api/guidance/getguidances"); + var res = APIPharmacist.GetRequest>($"api/guidance/getguidances?pharmacistid={APIPharmacist.Pharmacist.Id}"); return View(res); @@ -499,7 +499,7 @@ View(res); [HttpGet] public IActionResult CreateGuidance() { - ViewBag.Services = APIPharmacist.GetRequest>("api/service/getservices"); + ViewBag.Services = APIPharmacist.GetRequest>($"api/service/getservices?pharmacistid={APIPharmacist.Pharmacist.Id}"); return View(); } [HttpPost] @@ -524,8 +524,8 @@ View(res); [HttpGet] public IActionResult UpdateGuidance() { - ViewBag.Services = APIPharmacist.GetRequest>("api/service/getservices"); - ViewBag.Guidances = APIPharmacist.GetRequest>($"api/guidance/getguidances"); + ViewBag.Services = APIPharmacist.GetRequest>($"api/service/getservices?pharmacistid={APIPharmacist.Pharmacist.Id}"); + ViewBag.Guidances = APIPharmacist.GetRequest>($"api/guidance/getguidances?pharmacistid={APIPharmacist.Pharmacist.Id}"); return View(); } [HttpPost] @@ -552,7 +552,7 @@ View(res); [HttpGet] public IActionResult DeleteGuidance() { - ViewBag.Guidances = APIPharmacist.GetRequest>($"api/guidance/getguidances"); + ViewBag.Guidances = APIPharmacist.GetRequest>($"api/guidance/getguidances?pharmacistid={APIPharmacist.Pharmacist.Id}"); return View(); } diff --git a/VetClinic/PharmacistApp/Views/Home/MedicineAnimals.cshtml b/VetClinic/PharmacistApp/Views/Home/MedicineAnimals.cshtml index d7054a9..9b4d80f 100644 --- a/VetClinic/PharmacistApp/Views/Home/MedicineAnimals.cshtml +++ b/VetClinic/PharmacistApp/Views/Home/MedicineAnimals.cshtml @@ -22,7 +22,7 @@ @@ -50,7 +50,7 @@ $('#price').val(result.item1.price); $.map(result.item2, function (n) { console.log("#" + n); - $("#" + n).attr("selected", "selected") + $(`option[data-name=${n}]`).attr("selected", "selected") }); } diff --git a/VetClinic/PharmacistApp/Views/Home/UpdateGuidance.cshtml b/VetClinic/PharmacistApp/Views/Home/UpdateGuidance.cshtml index f11ef9a..d508714 100644 --- a/VetClinic/PharmacistApp/Views/Home/UpdateGuidance.cshtml +++ b/VetClinic/PharmacistApp/Views/Home/UpdateGuidance.cshtml @@ -52,7 +52,7 @@ btn-primary" /> success: function (result) { console.log(result.item2); $('#text').val(result.text); - $("#" + result.serviceId).attr("selected", "selected") + $(`option[data-name=${result.serviceId}]`).attr("selected", "selected") } }); diff --git a/VetClinic/PharmacistApp/Views/Home/UpdateService.cshtml b/VetClinic/PharmacistApp/Views/Home/UpdateService.cshtml index e11acc4..7a55acd 100644 --- a/VetClinic/PharmacistApp/Views/Home/UpdateService.cshtml +++ b/VetClinic/PharmacistApp/Views/Home/UpdateService.cshtml @@ -28,7 +28,7 @@ @@ -56,7 +56,7 @@ $('#price').val(result.item1.price); $.map(result.item2, function ( n ) { console.log("#" + n); - $("#" + n).attr("selected", "selected") + $(`option[data-name=${n}]`).attr("selected", "selected") }); } diff --git a/VetClinic/VetClinicContracts/SearchModels/GuidanceSearchModel.cs b/VetClinic/VetClinicContracts/SearchModels/GuidanceSearchModel.cs index bb4e0af..15e6772 100644 --- a/VetClinic/VetClinicContracts/SearchModels/GuidanceSearchModel.cs +++ b/VetClinic/VetClinicContracts/SearchModels/GuidanceSearchModel.cs @@ -10,6 +10,7 @@ namespace VetClinicContracts.SearchModels { public int? Id { get; set; } public string? Text { get; set; } + public int? PharmacistId { get; set; } public DateTime? DateFrom { get; set; } public DateTime? DateTo { get; set; } public int? ServiceId { get; set; } diff --git a/VetClinic/VetClinicDataBaseImplement/Implements/GuidanceStorage.cs b/VetClinic/VetClinicDataBaseImplement/Implements/GuidanceStorage.cs index a8214ed..9f9a46d 100644 --- a/VetClinic/VetClinicDataBaseImplement/Implements/GuidanceStorage.cs +++ b/VetClinic/VetClinicDataBaseImplement/Implements/GuidanceStorage.cs @@ -25,7 +25,7 @@ namespace VetClinicDataBaseImplement.Implements using var context = new VetClinicDatabase(); return context.Guidances.Include(x => x.Service).Where(x => (!model.Id.HasValue || model.Id == x.Id) && (!model.ServiceId.HasValue || model.ServiceId == x.ServiceId) && (!model.DateFrom.HasValue || model.DateFrom <= x.Date) - && (!model.DateTo.HasValue || model.DateTo >= x.Date)) + && (!model.DateTo.HasValue || model.DateTo >= x.Date) && (!model.PharmacistId.HasValue || model.PharmacistId == x.Service.PharmacistId)) .Select(x => x.GetViewModel) .ToList(); } diff --git a/VetClinic/VetClinicRestApi/Controllers/GuidanceController.cs b/VetClinic/VetClinicRestApi/Controllers/GuidanceController.cs index d2f2833..769448b 100644 --- a/VetClinic/VetClinicRestApi/Controllers/GuidanceController.cs +++ b/VetClinic/VetClinicRestApi/Controllers/GuidanceController.cs @@ -36,20 +36,20 @@ namespace VetClinicRestApi.Controllers } } [HttpGet] - public List? GetGuidances(int? serviceId = null) + public List? GetGuidances(int? pharmacistId = null) { try { - if (!serviceId.HasValue) + if (!pharmacistId.HasValue) return _guidance.ReadList(null); return _guidance.ReadList(new GuidanceSearchModel { - ServiceId = serviceId + PharmacistId = pharmacistId }); } catch (Exception ex) { - _logger.LogError(ex, "Ошибка получения списка рекомендааций услуги id ={ Id}", serviceId); + _logger.LogError(ex, "Ошибка получения списка рекомендааций пользователя id ={ Id}", pharmacistId); throw; } }