ну сделал создание

This commit is contained in:
gg12 darfren 2024-04-26 13:22:57 +04:00
parent c05c0faf16
commit 79c33f3f0d
4 changed files with 15 additions and 15 deletions

View File

@ -23,7 +23,7 @@ namespace PharmacistApp.Controllers
return Redirect("~/Home/Enter");
}
return
View(APIPharmacist.GetRequest<List<MedicineViewModel>>($"api/medicine/getmedicines?medicineId={
View(APIPharmacist.GetRequest<List<MedicineViewModel>>($"api/medicine/getmedicines?pharmacistid={
APIPharmacist.Pharmacist.Id}"));
}
@ -109,7 +109,7 @@ View(APIPharmacist.GetRequest<List<MedicineViewModel>>($"api/medicine/getmedicin
return;
}
public IActionResult Create()
public IActionResult CreateMedicine()
{
if (APIPharmacist.Pharmacist == null)
{
@ -151,7 +151,7 @@ View(APIPharmacist.GetRequest<List<MedicineViewModel>>($"api/medicine/getmedicin
}
[HttpPost]
public void DeleteMedicine(int shop)
public void DeleteMedicine(int medicine)
{
if (APIPharmacist.Pharmacist == null)
{
@ -159,23 +159,23 @@ View(APIPharmacist.GetRequest<List<MedicineViewModel>>($"api/medicine/getmedicin
}
APIPharmacist.PostRequest("api/medicine/deletemedicine", new MedicineBindingModel
{
Id = shop
Id = medicine
});
Response.Redirect("Index");
}
public IActionResult Update()
public IActionResult UpdateMedicine()
{
if (APIPharmacist.Pharmacist == null)
{
return Redirect("~/Home/Enter");
}
ViewBag.Medicines = APIPharmacist.GetRequest<List<MedicineViewModel>>("api/shop/getmedicines");
ViewBag.Medicines = APIPharmacist.GetRequest<List<MedicineViewModel>>("api/medicine/getmedicines");
return View();
}
[HttpPost]
public void Update(int medicine, string name, int price)
public void UpdateMedicine(int medicine, string name, int price)
{
if (APIPharmacist.Pharmacist == null)
{

View File

@ -15,7 +15,7 @@
<div class="row">
<div class="col-4">Цена:</div>
<div class="col-8">
<input type="text" name="address" id="address" />
<input type="text" name="price" id="price" />
</div>
</div>
<div class="row">

View File

@ -14,9 +14,9 @@
return;
}
<p>
<a asp-action="Create">Создать медикамент</a>
<a asp-action="Update">Обновить медикамент</a>
<a asp-action="Delete">Удалить медикамент</a>
<a asp-action="CreateMedicine">Создать медикамент</a>
<a asp-action="UpdateMedicine">Обновить медикамент</a>
<a asp-action="DeleteMedicine">Удалить медикамент</a>
</p>
<table class="table">
<thead>

View File

@ -11,7 +11,7 @@
<div class="row">
<div class="col-4">Медикамент:</div>
<div class="col-8">
<select id="medicine" name="medicine" class="form-control" asp-items="@(new SelectList(@ViewBag.Medicines, "Id", "MedicieName"))"></select>
<select id="medicine" name="medicine" class="form-control" asp-items="@(new SelectList(@ViewBag.Medicines, "Id", "MedicineName"))"></select>
</div>
</div>
<div class="row">
@ -20,7 +20,7 @@
</div>
<div class="row">
<div class="col-4">Цена:</div>
<div class="col-8"><input type="price" id="price" name="price" class="form-control" /></div>
<div class="col-8"><input type="number" id="price" name="price" class="form-control" /></div>
</div>
<table class="table">
@ -49,9 +49,9 @@
$.ajax({
method: "GET",
url: "/Home/GetMedicine",
data: { medcineId: medicine },
data: { medicineId: medicine },
success: function (result) {
$('#medicinename').val(result.item1.MedicineName);
$('#name').val(result.item1.MedicineName);
$('#price').val(result.item1.Price);
$('#table-elements').html(result.item2);
}