СДЕЛАЛ СДЕЛАЛ СДЕЛАЛ УРААААААААААА

This commit is contained in:
gg12 darfren 2024-04-27 18:51:12 +04:00
parent f6c25cf968
commit 7214604c67
2 changed files with 12 additions and 12 deletions

View File

@ -239,7 +239,7 @@ View(APIPharmacist.GetRequest<List<MedicineViewModel>>($"api/medicine/getmedicin
}
[HttpGet]
public Tuple<MedicineViewModel, string>? GetMedicine(int medicineId)
public Tuple<MedicineViewModel, List<string>>? GetMedicine(int medicineId)
{
if (APIPharmacist.Pharmacist == null)
{
@ -250,15 +250,8 @@ View(APIPharmacist.GetRequest<List<MedicineViewModel>>($"api/medicine/getmedicin
{
return default;
}
string table = "";
for (int i = 0; i < result.Item2.Count; i++)
{
var animal = result.Item2[i];
table += "<tr>";
table += $"<td>{animal}</td>";
table += "</tr>";
}
return Tuple.Create(result.Item1, table);
return result;
}
[HttpGet]

View File

@ -25,10 +25,10 @@
<div class="row">
<div class="col-4">Животные:</div>
<div class="col-8">
<select name="animals" class="form-control" multiple size="6" id="animals">
<select name="animals" class="form-control" multiple size="5" id="animals">
@foreach (var animal in ViewBag.Animals)
{
<option value="@animal.Id">@animal.AnimalName</option>
<option value="@animal.Id" id="@animal.AnimalName">@animal.AnimalName</option>
}
</select>
</div>
@ -44,15 +44,22 @@
<script>
function check() {
var medicine = $('#medicine').val();
$("#animals option:selected").removeAttr("selected");
if (medicine) {
$.ajax({
method: "GET",
url: "/Home/GetMedicine",
data: { medicineId: medicine },
success: function (result) {
console.log(result.item2);
$('#name').val(result.item1.medicineName);
$('#price').val(result.item1.price);
$.map(result.item2, function ( n ) {
console.log("#" + n);
$("#" + n).attr("selected", "selected")
});
}
});
};
}