Исполнитель: вроде доделал всё
This commit is contained in:
parent
2406dbd831
commit
a99c69ffc9
@ -52,7 +52,7 @@ namespace VeterinaryDatabaseImplement.Models
|
||||
return _purchasePets;
|
||||
}
|
||||
}
|
||||
public static Pet? Create(VeterinaryDatabase context, PetBindingModel model)
|
||||
public static Pet? Create(PetBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
@ -64,15 +64,7 @@ namespace VeterinaryDatabaseImplement.Models
|
||||
PetName = model.PetName,
|
||||
PetType = model.PetType,
|
||||
PetBreed = model.PetBreed,
|
||||
PetGender = model.PetGender,
|
||||
Visits = model.VisitPets.Select(x => new VisitPet
|
||||
{
|
||||
Visit = context.Visits.First(y => y.Id == x.Key)
|
||||
}).ToList(),
|
||||
Purchases = model.PurchasePets.Select(x => new PurchasePet
|
||||
{
|
||||
Purchase = context.Purchases.First(y => y.Id == x.Key)
|
||||
}).ToList()
|
||||
PetGender = model.PetGender
|
||||
};
|
||||
}
|
||||
public void Update(PetBindingModel model)
|
||||
|
@ -7,15 +7,11 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Content Remove="Views\Home\CreatePet.cshtml" />
|
||||
<Content Remove="Views\Home\CreateVisit.cshtml" />
|
||||
<Content Remove="Views\Home\DeletePet.cshtml" />
|
||||
<Content Remove="Views\Home\UpdatePet.cshtml" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Include="Views\Home\CreatePet.cshtml" />
|
||||
<Compile Include="Views\Home\DeletePet.cshtml" />
|
||||
<Compile Include="Views\Home\UpdatePet.cshtml" />
|
||||
</ItemGroup>
|
||||
|
||||
|
@ -18,13 +18,13 @@
|
||||
<input type="text" name="type" id="type" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="row">
|
||||
<div class="col-4">Порода:</div>
|
||||
<div class="col-8">
|
||||
<input type="text" name="breed" id="breed" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="row">
|
||||
<div class="col-4">Пол:</div>
|
||||
<div class="col-8">
|
||||
<input type="text" name="gender" id="gender" />
|
||||
|
@ -1,6 +1,56 @@
|
||||
namespace VeterinaryShowOwnerApp.Views.Home
|
||||
{
|
||||
public class CreatePurchase
|
||||
{
|
||||
}
|
||||
@{
|
||||
ViewData["Title"] = "CreatePurchase";
|
||||
}
|
||||
|
||||
<div class="text-center">
|
||||
<h2 class="display-4">Создание покупки</h2>
|
||||
</div>
|
||||
<form method="post">
|
||||
<div class="row">
|
||||
<div class="col-4">Лекарство:</div>
|
||||
<div class="col-8">
|
||||
<select id="drug" name="drug" class="form-control" asp-items="@(new SelectList(@ViewBag.Drugs,"Id", "DrugName"))"></select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Количество:</div>
|
||||
<div class="col-8">
|
||||
<input type="text" name="count" id="count" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Сумма:</div>
|
||||
<div class="col-8">
|
||||
<input type="text" id="sum" name="sum" readonly />
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-8"></div>
|
||||
<div class="col-4">
|
||||
<input type="submit" value="Создать" class="btn btn-primary" />
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<script>
|
||||
$('#drug').on('change', function () {
|
||||
check();
|
||||
});
|
||||
$('#count').on('change', function () {
|
||||
check();
|
||||
});
|
||||
|
||||
function check() {
|
||||
var count = $('#count').val();
|
||||
var drug = $('#drug').val();
|
||||
if (count && drug) {
|
||||
$.ajax({
|
||||
method: "POST",
|
||||
url: "/Home/Calc",
|
||||
data: { count: count, drug: drug },
|
||||
success: function (result) {
|
||||
$("#sum").val(result);
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
</script>
|
@ -1,4 +1,4 @@
|
||||
@{
|
||||
n@{
|
||||
ViewData["Title"] = "DeletePet";
|
||||
}
|
||||
<div class="text-center">
|
||||
|
@ -6,5 +6,5 @@
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "*",
|
||||
"IPAddress": "http://localhost:"
|
||||
"IPAddress": "http://localhost:5156/"
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user