Compare commits
2 Commits
7214604c67
...
0728fb599c
Author | SHA1 | Date | |
---|---|---|---|
0728fb599c | |||
cde48f8eef |
@ -3,6 +3,7 @@ using VetClinicAdminApp.Models;
|
||||
using System.Diagnostics;
|
||||
using VetClinicContracts.BindingModels;
|
||||
using VetClinicContracts.ViewModels;
|
||||
using VetClinicDataModels.Models;
|
||||
|
||||
|
||||
namespace VetClinicAdminApp.Controllers
|
||||
@ -25,6 +26,26 @@ namespace VetClinicAdminApp.Controllers
|
||||
return
|
||||
View(APIAdmin.GetRequest<List<VisitViewModel>>($"api/visit/getvisits?vistId={APIAdmin.Admin.Id}"));
|
||||
|
||||
}
|
||||
public IActionResult IndexAnimals()
|
||||
{
|
||||
if (APIAdmin.Admin == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
return
|
||||
View(APIAdmin.GetRequest<List<AnimalViewModel>>($"api/animal/getanimallist?animalId={APIAdmin.Admin.Id}"));
|
||||
|
||||
}
|
||||
public IActionResult IndexVaccinations()
|
||||
{
|
||||
if (APIAdmin.Admin == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
return
|
||||
View(APIAdmin.GetRequest<List<VaccinationViewModel>>($"api/vaccination/getvaccinations?vaccinationId={APIAdmin.Admin.Id}"));
|
||||
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
@ -116,11 +137,22 @@ View(APIAdmin.GetRequest<List<VisitViewModel>>($"api/visit/getvisits?vistId={API
|
||||
}
|
||||
return View();
|
||||
}
|
||||
|
||||
|
||||
public IActionResult CreateAnimal()
|
||||
{
|
||||
if (APIAdmin.Admin == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
return View();
|
||||
}
|
||||
public IActionResult CreateVaccination()
|
||||
{
|
||||
ViewBag.Animals = APIAdmin.GetRequest<List<AnimalViewModel>>("api/animal/getanimallist");
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void CreateVisit(string name, DateTime visitdate)
|
||||
public void Create(string name, DateTime visitdate)
|
||||
{
|
||||
if (APIAdmin.Admin == null)
|
||||
{
|
||||
@ -138,8 +170,51 @@ View(APIAdmin.GetRequest<List<VisitViewModel>>($"api/visit/getvisits?vistId={API
|
||||
});
|
||||
Response.Redirect("Index");
|
||||
}
|
||||
|
||||
public IActionResult DeleteMedicine()
|
||||
[HttpPost]
|
||||
public void CreateAnimal(string animalname,string family)
|
||||
{
|
||||
if (APIAdmin.Admin == null)
|
||||
{
|
||||
throw new Exception("Âû êàê ñþäà ïîïàëè? Ñþäà âõîä òîëüêî àâòîðèçîâàííûì");
|
||||
}
|
||||
if (string.IsNullOrEmpty(animalname))
|
||||
{
|
||||
throw new Exception("Îøèáêà â ââåäåííûõ äàííûõ");
|
||||
}
|
||||
APIAdmin.PostRequest("api/animal/createanimal", new AnimalBindingModel
|
||||
{
|
||||
AnimalName = animalname,
|
||||
Family = family,
|
||||
AdminId = APIAdmin.Admin.Id
|
||||
});
|
||||
Response.Redirect("IndexAnimals");
|
||||
}
|
||||
[HttpPost]
|
||||
public void CreateVaccination(int animale, string name, double cost,DateTime date)
|
||||
{
|
||||
if (APIAdmin.Admin == null)
|
||||
{
|
||||
throw new Exception("Âû êàê ñþäà ïîïàëè? Ñþäà âõîä òîëüêî àâòîðèçîâàííûì");
|
||||
}
|
||||
if (string.IsNullOrEmpty(name))
|
||||
{
|
||||
throw new Exception("Îøèáêà â ââåäåííûõ äàííûõ");
|
||||
}
|
||||
if (cost <= 0)
|
||||
{
|
||||
throw new Exception("Цена должна быть выше 0");
|
||||
}
|
||||
APIAdmin.PostRequest("api/vaccination/createvaccination", new VaccinationBindingModel
|
||||
{
|
||||
NameVaccination = name,
|
||||
AnimalId = animale,
|
||||
CostVaccination = cost,
|
||||
DateStamp = date
|
||||
});
|
||||
Response.Redirect("IndexVaccinations");
|
||||
}
|
||||
|
||||
public IActionResult Delete()
|
||||
{
|
||||
if (APIAdmin.Admin == null)
|
||||
{
|
||||
@ -150,7 +225,7 @@ View(APIAdmin.GetRequest<List<VisitViewModel>>($"api/visit/getvisits?vistId={API
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void DeleteVisit(int shop)
|
||||
public void DeleteVisit(int visit)
|
||||
{
|
||||
if (APIAdmin.Admin == null)
|
||||
{
|
||||
@ -158,18 +233,64 @@ View(APIAdmin.GetRequest<List<VisitViewModel>>($"api/visit/getvisits?vistId={API
|
||||
}
|
||||
APIAdmin.PostRequest("api/visit/deletevisit", new VisitBindingModel
|
||||
{
|
||||
Id = shop
|
||||
Id = visit
|
||||
});
|
||||
Response.Redirect("Index");
|
||||
}
|
||||
|
||||
public IActionResult DeleteAnimal()
|
||||
{
|
||||
if (APIAdmin.Admin == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
ViewBag.Animals = APIAdmin.GetRequest<List<AnimalViewModel>>($"api/animal/getanimallist?adminid={APIAdmin.Admin.Id}");
|
||||
return View();
|
||||
}
|
||||
public IActionResult DeleteVaccination()
|
||||
{
|
||||
if (APIAdmin.Admin == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
ViewBag.Vaccinations = APIAdmin.GetRequest<List<VaccinationViewModel>>($"api/vaccination/getvaccinations?adminid={APIAdmin.Admin.Id}");
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void DeleteAnimal(int animal)
|
||||
{
|
||||
if (APIAdmin.Admin == null)
|
||||
{
|
||||
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
|
||||
}
|
||||
APIAdmin.PostRequest("api/animal/deleteanimal", new AnimalBindingModel
|
||||
{
|
||||
Id = animal
|
||||
});
|
||||
Response.Redirect("IndexAnimals");
|
||||
}
|
||||
[HttpPost]
|
||||
public void DeleteVaccination(int vaccination)
|
||||
{
|
||||
if (APIAdmin.Admin == null)
|
||||
{
|
||||
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
|
||||
}
|
||||
APIAdmin.PostRequest("api/vaccination/deletevaccination", new VaccinationBindingModel
|
||||
{
|
||||
Id = vaccination
|
||||
});
|
||||
Response.Redirect("IndexVaccinations");
|
||||
}
|
||||
|
||||
public IActionResult Update()
|
||||
{
|
||||
if (APIAdmin.Admin == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
ViewBag.Medicines = APIAdmin.GetRequest<List<MedicineViewModel>>("api/shop/getvisits");
|
||||
ViewBag.Medicines = APIAdmin.GetRequest<List<MedicineViewModel>>("api/visit/getvisits");
|
||||
return View();
|
||||
}
|
||||
|
||||
@ -180,7 +301,7 @@ View(APIAdmin.GetRequest<List<VisitViewModel>>($"api/visit/getvisits?vistId={API
|
||||
{
|
||||
throw new Exception("Âû êàê ñþäà ïîïàëè? Ñþäà âõîä òîëüêî àâòîðèçîâàííûì");
|
||||
}
|
||||
if (string.IsNullOrEmpty(name) )
|
||||
if (string.IsNullOrEmpty(name))
|
||||
{
|
||||
throw new Exception("Îøèáêà â ââåäåííûõ äàííûõ");
|
||||
}
|
||||
@ -192,7 +313,69 @@ View(APIAdmin.GetRequest<List<VisitViewModel>>($"api/visit/getvisits?vistId={API
|
||||
});
|
||||
Response.Redirect("Index");
|
||||
}
|
||||
public IActionResult UpdateAnimal()
|
||||
{
|
||||
if (APIAdmin.Admin == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
ViewBag.Animals = APIAdmin.GetRequest<List<AnimalViewModel>>($"api/animal/getanimallist?adminid={APIAdmin.Admin.Id}");
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void UpdateAnimal(int animal, string name, string family)
|
||||
{
|
||||
if (APIAdmin.Admin == null)
|
||||
{
|
||||
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
|
||||
}
|
||||
if (string.IsNullOrEmpty(name))
|
||||
{
|
||||
throw new Exception("Ошибка в введенных данных");
|
||||
}
|
||||
APIAdmin.PostRequest("api/animal/updateanimal", new AnimalBindingModel
|
||||
{
|
||||
Id = animal,
|
||||
AnimalName = name,
|
||||
Family = family
|
||||
|
||||
});
|
||||
Response.Redirect("IndexAnimals");
|
||||
}
|
||||
public IActionResult UpdateVaccination()
|
||||
{
|
||||
if (APIAdmin.Admin == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
ViewBag.Vaccinations = APIAdmin.GetRequest<List<VaccinationViewModel>>($"api/vaccination/getvaccinations?adminid={APIAdmin.Admin.Id}");
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void UpdateVaccination(int animale,int vaccination, string name, double cost, DateTime date)
|
||||
{
|
||||
if (APIAdmin.Admin == null)
|
||||
{
|
||||
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
|
||||
}
|
||||
if (string.IsNullOrEmpty(name))
|
||||
{
|
||||
throw new Exception("Ошибка в введенных данных");
|
||||
}
|
||||
APIAdmin.PostRequest("api/vaccination/updatevaccination", new VaccinationBindingModel
|
||||
{
|
||||
|
||||
Id = vaccination,
|
||||
AnimalId = animale,
|
||||
NameVaccination = name,
|
||||
CostVaccination = cost,
|
||||
DateStamp = date
|
||||
|
||||
});
|
||||
Response.Redirect("IndexVaccination");
|
||||
}
|
||||
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
|
||||
public IActionResult Error()
|
||||
{
|
||||
@ -200,7 +383,7 @@ View(APIAdmin.GetRequest<List<VisitViewModel>>($"api/visit/getvisits?vistId={API
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public Tuple<VisitViewModel, string>? GetMedicine(int visitId)
|
||||
public Tuple<VisitViewModel, string>? GetVisit(int visitId)
|
||||
{
|
||||
if (APIAdmin.Admin == null)
|
||||
{
|
||||
|
@ -6,12 +6,7 @@
|
||||
<h2 class="display-4">Создание визита</h2>
|
||||
</div>
|
||||
<form method="post">
|
||||
<div class="row">
|
||||
<div class="col-4">Животное:</div>
|
||||
<div class="col-8">
|
||||
<select id="animal" name="animal" class="form-control" asp-items="@(new SelectList(@ViewBag.Snacks, "Id", "AnimalName"))"></select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-4">Название:</div>
|
||||
<div class="col-8">
|
||||
@ -21,7 +16,7 @@
|
||||
<div class="row">
|
||||
<div class="col-4">Дата:</div>
|
||||
<div class="col-8">
|
||||
<input type="date" id="date" name="date" readonly />
|
||||
<input type="date" id="date" name="date"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
|
29
VetClinic/VetClinicAdminApi/Views/Home/CreateAnimal.cshtml
Normal file
29
VetClinic/VetClinicAdminApi/Views/Home/CreateAnimal.cshtml
Normal file
@ -0,0 +1,29 @@
|
||||
@{
|
||||
ViewData["Title"] = "CreateAnimal";
|
||||
}
|
||||
|
||||
<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">
|
||||
<input type="text" name="animalname" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Семейство:</div>
|
||||
<div class="col-8">
|
||||
<input type="text" name="Family" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-8"></div>
|
||||
<div class="col-4">
|
||||
<input type="submit" value="Создать" class="btn btn-primary" />
|
||||
</div>
|
||||
</div>
|
||||
<script src="~/lib/jquery/dist/jquery.min.js"></script>
|
||||
</form>
|
||||
|
@ -0,0 +1,58 @@
|
||||
@{
|
||||
ViewData["Title"] = "CreateVaccination";
|
||||
}
|
||||
|
||||
<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="animal" name="animal" class="form-control" asp-items="@(new SelectList(@ViewBag.Animals, "Id", "AnimalName"))"></select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Название:</div>
|
||||
<div class="col-8">
|
||||
<input type="text" name="name" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Цена:</div>
|
||||
<div class="col-8">
|
||||
<input type="text" name="cost" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Дата:</div>
|
||||
<div class="col-8">
|
||||
<input type="date" id="date" name="date"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-8"></div>
|
||||
<div class="col-4">
|
||||
<input type="submit" value="Создать" class="btn btn-primary" />
|
||||
</div>
|
||||
</div>
|
||||
<script src="~/lib/jquery/dist/jquery.min.js"></script>
|
||||
</form>
|
||||
<script>
|
||||
$('#animal').on('change', function () {
|
||||
check();
|
||||
});
|
||||
function check() {
|
||||
if (snack) {
|
||||
$.ajax({
|
||||
method: "POST",
|
||||
url: "/Home/GetAnimal",
|
||||
data: { animal: animal },
|
||||
success: function (result) {
|
||||
$("#animal").val(result);
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
</script>
|
||||
|
18
VetClinic/VetClinicAdminApi/Views/Home/DeleteAnimal.cshtml
Normal file
18
VetClinic/VetClinicAdminApi/Views/Home/DeleteAnimal.cshtml
Normal file
@ -0,0 +1,18 @@
|
||||
@{
|
||||
ViewData["Title"] = "DeleteAnimal";
|
||||
}
|
||||
<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="animal" name="animal" class="form-control" asp-items="@(new SelectList(@ViewBag.Animals, "Id", "AnimalName"))"></select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4"></div>
|
||||
<div class="col-8"><input type="submit" value="Удалить" class="btn btn-danger" /></div>
|
||||
</div>
|
||||
</form>
|
@ -0,0 +1,37 @@
|
||||
@{
|
||||
ViewData["Title"] = "CreateVaccination";
|
||||
}
|
||||
|
||||
<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="vaccination" name="vaccination" class="form-control" asp-items="@(new SelectList(@ViewBag.Vaccinations, "Id", "NameVaccination"))"></select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4"></div>
|
||||
<div class="col-8"><input type="submit" value="Удалить" class="btn btn-danger" /></div>
|
||||
</div>
|
||||
</form>
|
||||
<script>
|
||||
$('#vaccination').on('change', function () {
|
||||
check();
|
||||
});
|
||||
function check() {
|
||||
if (snack) {
|
||||
$.ajax({
|
||||
method: "POST",
|
||||
url: "/Home/GetVaccination",
|
||||
data: { vaccination: vaccination },
|
||||
success: function (result) {
|
||||
$("#vaccination").val(result);
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
</script>
|
||||
|
@ -27,9 +27,6 @@
|
||||
<th>
|
||||
Номер
|
||||
</th>
|
||||
<th>
|
||||
Животоное
|
||||
</th>
|
||||
<th>
|
||||
Название
|
||||
</th>
|
||||
@ -46,9 +43,7 @@
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Id)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.AnimalName)
|
||||
</td>
|
||||
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.NameVisit)
|
||||
</td>
|
||||
|
62
VetClinic/VetClinicAdminApi/Views/Home/IndexAnimals.cshtml
Normal file
62
VetClinic/VetClinicAdminApi/Views/Home/IndexAnimals.cshtml
Normal file
@ -0,0 +1,62 @@
|
||||
@using VetClinicContracts.ViewModels
|
||||
|
||||
@model List<AnimalViewModel>
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "IndexAnimals";
|
||||
}
|
||||
|
||||
<div class="text-center">
|
||||
<h1 class="display-4">Животные</h1>
|
||||
</div>
|
||||
|
||||
<div class="text-center">
|
||||
@{
|
||||
if (Model == null)
|
||||
{
|
||||
<h3 class="display-4">Авторизируйтесь</h3>
|
||||
return;
|
||||
}
|
||||
<p>
|
||||
<a asp-action="UpdateAnimal">Редактировать животное</a>
|
||||
<a asp-action="DeleteAnimal">Удалить животное</a>
|
||||
</p>
|
||||
<p>
|
||||
<a asp-action="CreateAnimal">Создать животное</a>
|
||||
</p>
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
Номер
|
||||
</th>
|
||||
<th>
|
||||
Название
|
||||
</th>
|
||||
<th>
|
||||
Семейство
|
||||
</th>
|
||||
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var item in Model)
|
||||
{
|
||||
<tr>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Id)
|
||||
</td>
|
||||
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.AnimalName)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Family)
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
}
|
||||
</div>
|
@ -0,0 +1,64 @@
|
||||
@using VetClinicContracts.ViewModels
|
||||
|
||||
@model List<VaccinationViewModel>
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "IndexVaccinations";
|
||||
}
|
||||
|
||||
<div class="text-center">
|
||||
<h1 class="display-4">Прививки</h1>
|
||||
</div>
|
||||
|
||||
<div class="text-center">
|
||||
@{
|
||||
if (Model == null)
|
||||
{
|
||||
<h3 class="display-4">Авторизируйтесь</h3>
|
||||
return;
|
||||
}
|
||||
<p>
|
||||
<a asp-action="UpdateVaccination">Изменить прививку</a>
|
||||
<a asp-action="DeleteVaccination">Удалить прививку</a>
|
||||
</p>
|
||||
<p>
|
||||
<a asp-action="CreateVaccination">Создать прививку</a>
|
||||
</p>
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
Номер
|
||||
</th>
|
||||
<th>
|
||||
Название
|
||||
</th>
|
||||
<th>
|
||||
Дата
|
||||
</th>
|
||||
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var item in Model)
|
||||
{
|
||||
<tr>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Id)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.NameVaccination)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.CostVaccination)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.DateStamp)
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
}
|
||||
</div>
|
56
VetClinic/VetClinicAdminApi/Views/Home/UpdateAnimal.cshtml
Normal file
56
VetClinic/VetClinicAdminApi/Views/Home/UpdateAnimal.cshtml
Normal file
@ -0,0 +1,56 @@
|
||||
@using VetClinicContracts.ViewModels;
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "UpdateAnimal";
|
||||
}
|
||||
|
||||
<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="animal" name="animal" class="form-control" asp-items="@(new SelectList(@ViewBag.Animals, "Id", "AnimalName"))"></select>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Название:</div>
|
||||
<div class="col-8"><input type="text" name="name" id="name" class="form-control" /></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Семейство:</div>
|
||||
<div class="col-8"><input type="text" id="family" name="family" class="form-control" /></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>
|
||||
|
||||
@section Scripts
|
||||
{
|
||||
<script>
|
||||
function check() {
|
||||
var animal = $('#animal').val();
|
||||
if (animal) {
|
||||
$.ajax({
|
||||
method: "GET",
|
||||
url: "/Home/GetAnimal",
|
||||
data: { animalId: animal },
|
||||
success: function (result) {
|
||||
$('#name').val(result.item1.animalName);
|
||||
$('#family').val(result.item1.price);
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
check();
|
||||
$('#animal').on('change', function () {
|
||||
check();
|
||||
});
|
||||
</script>
|
||||
}
|
@ -0,0 +1,56 @@
|
||||
@{
|
||||
ViewData["Title"] = "UpdateVaccination";
|
||||
}
|
||||
|
||||
<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="vaccination" name="vaccination" class="form-control" asp-items="@(new SelectList(@ViewBag.Vaccinations, "Id", "NameVaccination"))"></select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Название:</div>
|
||||
<div class="col-8">
|
||||
<input type="text" name="name" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Цена:</div>
|
||||
<div class="col-8">
|
||||
<input type="text" name="cost" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Дата:</div>
|
||||
<div class="col-8">
|
||||
<input type="date" id="date" name="date"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-8"></div>
|
||||
<div class="col-4"><input type="submit" value="Сохранить" class="btn btn-primary" /></div>
|
||||
</div>
|
||||
<script src="~/lib/jquery/dist/jquery.min.js"></script>
|
||||
</form>
|
||||
<script>
|
||||
$('#animal').on('change', function () {
|
||||
check();
|
||||
});
|
||||
function check() {
|
||||
if (snack) {
|
||||
$.ajax({
|
||||
method: "POST",
|
||||
url: "/Home/GetAnimal",
|
||||
data: { animal: animal },
|
||||
success: function (result) {
|
||||
$("#animal").val(result);
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
</script>
|
||||
|
@ -3,7 +3,7 @@
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>@ViewData["Title"] - IceCreamShopClientApp</title>
|
||||
<title>@ViewData["Title"] - VetClinicAdminApp</title>
|
||||
<link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.min.css" />
|
||||
<link rel="stylesheet" href="~/css/site.css" />
|
||||
<script src="~/lib/jquery/dist/jquery.min.js"></script>
|
||||
@ -13,7 +13,7 @@
|
||||
<header>
|
||||
<nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bgwhite border-bottom box-shadow mb-3">
|
||||
<div class="container">
|
||||
<a class="navbar-brand" asp-area="" asp-controller="Home" aspaction="Index">Магазин мороженного</a>
|
||||
<a class="navbar-brand" asp-area="" asp-controller="Home" aspaction="Index">Айболит</a>
|
||||
<button class="navbar-toggler" type="button" datatoggle="collapse" data-target=".navbar-collapse" ariacontrols="navbarSupportedContent"
|
||||
aria-expanded="false" aria-label="Toggle navigation">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
@ -21,7 +21,13 @@
|
||||
<div class="navbar-collapse collapse d-sm-inline-flex flex-smrow-reverse">
|
||||
<ul class="navbar-nav flex-grow-1">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="Index">Медикаменты</a>
|
||||
<a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="IndexAnimals">Животные</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="IndexVaccinations">Прививки</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="Index">Визиты</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="Privacy">Личные данные</a>
|
||||
@ -42,11 +48,6 @@
|
||||
@RenderBody()
|
||||
</main>
|
||||
</div>
|
||||
<footer class="border-top footer text-muted">
|
||||
<div class="container">
|
||||
© 2024 - Магазин мороженного - <a asp-area="" aspcontroller="Home" asp-action="Privacy">Личные данные</a>
|
||||
</div>
|
||||
</footer>
|
||||
<script src="~/js/site.js" asp-append-version="true"></script>
|
||||
@RenderSection("Scripts", required: false)
|
||||
</body>
|
||||
|
@ -98,7 +98,7 @@ namespace VetClinicBusinessLogic.BusinessLogics
|
||||
}
|
||||
if (string.IsNullOrEmpty(model.NameVaccination))
|
||||
{
|
||||
throw new ArgumentNullException("Нет текста рекомендации",
|
||||
throw new ArgumentNullException("Нет имени прививки",
|
||||
nameof(model.NameVaccination));
|
||||
}
|
||||
if (model.CostVaccination <= 0)
|
||||
@ -106,7 +106,7 @@ namespace VetClinicBusinessLogic.BusinessLogics
|
||||
throw new ArgumentNullException("Цена привики должна быть больше 0", nameof(model.CostVaccination));
|
||||
}
|
||||
|
||||
_logger.LogInformation("Guidance. NameVaccination:{NameVaccination}. CostVaccination:{CostVaccination}", model.NameVaccination, model.CostVaccination);
|
||||
_logger.LogInformation("Vaccination. NameVaccination:{NameVaccination}. CostVaccination:{CostVaccination}", model.NameVaccination, model.CostVaccination);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,16 +3,17 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using VetClinicDataModels.Models;
|
||||
|
||||
namespace VetClinicContracts.BindingModels
|
||||
{
|
||||
public class VaccinationBindingModel
|
||||
public class VaccinationBindingModel : IVaccinationModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public int AnimalId { get; set; }
|
||||
public string NameVaccination { get; set; } = string.Empty;
|
||||
public double CostVaccination { get; set; }
|
||||
public DateTime? DateStamp { get; set; }
|
||||
public DateTime DateStamp { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -10,14 +10,14 @@ namespace VetClinicContracts.ViewModels
|
||||
public class VaccinationViewModel : IVaccinationModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public int AnimalId { get; set; }
|
||||
[DisplayName("Название прививки")]
|
||||
public string NameVaccination { get; set; } = string.Empty;
|
||||
[DisplayName("Цена")]
|
||||
public double CostVaccination { get; set; }
|
||||
[DisplayName("Дата")]
|
||||
public DateTime? DateStamp { get; set; }
|
||||
public DateTime DateStamp { get; set; }
|
||||
[DisplayName("Животное")]
|
||||
public string AnimalName { get; set; } = string.Empty;
|
||||
public int AnimalId { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ namespace VetClinicDataBaseImplement.Models
|
||||
ServiceId = model.ServiceId,
|
||||
Text = model.Text,
|
||||
Date = model.Date,
|
||||
Service = context.Services.FirstOrDefault(x => x.Id == model.ServiceId),
|
||||
Service = context.Services.FirstOrDefault(x => x.Id == model.ServiceId)
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -14,17 +14,17 @@ namespace VetClinicDataBaseImplement.Models
|
||||
{
|
||||
public class Vaccination : IVaccinationModel
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
public int Id { get; set; }
|
||||
[Required]
|
||||
public int AnimalId { get; private set; }
|
||||
public virtual Animal Animal { get; private set; }
|
||||
public int AnimalId { get; set; }
|
||||
public virtual Animal Animal { get; set; }
|
||||
[Required]
|
||||
public string NameVaccination { get; private set; } = string.Empty;
|
||||
public string NameVaccination { get; set; } = string.Empty;
|
||||
[Required]
|
||||
public double CostVaccination { get; private set; }
|
||||
public double CostVaccination { get; set; }
|
||||
[Required]
|
||||
public DateTime? DateStamp { get; private set; }
|
||||
public static Vaccination? Create(VetClinicDatabase context, VaccinationBindingModel model)
|
||||
public DateTime DateStamp { get; set; }
|
||||
public static Vaccination? Create(VetClinicDatabase context, VaccinationBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
@ -37,7 +37,7 @@ namespace VetClinicDataBaseImplement.Models
|
||||
NameVaccination = model.NameVaccination,
|
||||
CostVaccination = model.CostVaccination,
|
||||
DateStamp = model.DateStamp,
|
||||
|
||||
Animal = context.Animals.FirstOrDefault(x => x.Id == model.AnimalId)
|
||||
};
|
||||
}
|
||||
|
||||
@ -55,10 +55,11 @@ namespace VetClinicDataBaseImplement.Models
|
||||
|
||||
public VaccinationViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
AnimalId = AnimalId,
|
||||
NameVaccination = NameVaccination,
|
||||
CostVaccination = CostVaccination,
|
||||
DateStamp = DateStamp,
|
||||
Id = Id,
|
||||
AnimalName = Animal.AnimalName
|
||||
};
|
||||
}
|
||||
|
@ -8,9 +8,10 @@ namespace VetClinicDataModels.Models
|
||||
{
|
||||
public interface IVaccinationModel : IId
|
||||
{
|
||||
int Id { get; }
|
||||
int AnimalId { get; }
|
||||
string NameVaccination { get; }
|
||||
double CostVaccination { get; }
|
||||
DateTime? DateStamp { get; }
|
||||
DateTime DateStamp { get; }
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,84 @@
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using VetClinicContracts.BindingModels;
|
||||
using VetClinicContracts.BusinessLogicsContracts;
|
||||
using VetClinicContracts.SearchModels;
|
||||
using VetClinicContracts.ViewModels;
|
||||
using VetClinicDataBaseImplement.Models;
|
||||
|
||||
namespace VetClinicRestApi.Controllers
|
||||
{
|
||||
[Route("api/[controller]/[action]")]
|
||||
[ApiController]
|
||||
public class VaccinationController : Controller
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IVaccinationLogic _vaccination;
|
||||
|
||||
public VaccinationController(ILogger<VaccinationController> logger,
|
||||
IVaccinationLogic vaccination)
|
||||
{
|
||||
_logger = logger;
|
||||
_vaccination = vaccination;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public List<VaccinationViewModel>? GetVaccinations(int animalId)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _vaccination.ReadList(new VaccinationSearchModel
|
||||
{
|
||||
AnimalId = animalId
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка получения списка привиовк животного id ={ Id}", animalId);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void CreateVaccination(VaccinationBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
_vaccination.Create(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка создания прививки");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public bool UpdateVaccination(VaccinationBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _vaccination.Update(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Не удалось обновить привику");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public bool DeleteVaccination(VaccinationBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _vaccination.Delete(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка удаления привики");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user