Compare commits
5 Commits
77484409f6
...
62570a8348
Author | SHA1 | Date | |
---|---|---|---|
|
62570a8348 | ||
|
48f2eb83b4 | ||
|
c6a72b65b7 | ||
0728fb599c | |||
cde48f8eef |
@ -321,148 +321,168 @@ View(APIPharmacist.GetRequest<List<MedicineViewModel>>($"api/medicine/getmedicin
|
||||
return result;
|
||||
}
|
||||
|
||||
//public IActionResult CreateService()
|
||||
//{
|
||||
// if (APIPharmacist.Pharmacist == null)
|
||||
// {
|
||||
// return Redirect("~/Home/Enter");
|
||||
// }
|
||||
// ViewBag.Medicines = APIPharmacist.GetRequest<List<MedicineViewModel>>($"api/animal/getmedicines");
|
||||
public IActionResult Services()
|
||||
{
|
||||
if (APIPharmacist.Pharmacist == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
return
|
||||
View(APIPharmacist.GetRequest<List<ServiceViewModel>>($"api/service/getservices?pharmacistid={APIPharmacist.Pharmacist.Id}"));
|
||||
|
||||
// return View();
|
||||
//}
|
||||
}
|
||||
|
||||
|
||||
public IActionResult CreateService()
|
||||
{
|
||||
if (APIPharmacist.Pharmacist == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
ViewBag.Medicines = APIPharmacist.GetRequest<List<MedicineViewModel>>($"api/medicine/getmedicines");
|
||||
|
||||
return View();
|
||||
}
|
||||
|
||||
|
||||
|
||||
//[HttpPost]
|
||||
//public void CreateService(string name, string price, List<int> medicines)
|
||||
//{
|
||||
// if (APIPharmacist.Pharmacist == null)
|
||||
// {
|
||||
// throw new Exception("Âû êàê ñþäà ïîïàëè? Ñþäà âõîä òîëüêî àâòîðèçîâàííûì");
|
||||
// }
|
||||
// double _price;
|
||||
// try
|
||||
// {
|
||||
// _price = Convert.ToDouble(price);
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// throw new Exception("Îøèáêà â ââåäåííûõ äàííûõ");
|
||||
// }
|
||||
// if (string.IsNullOrEmpty(name) || _price <= 0)
|
||||
// {
|
||||
// throw new Exception("Îøèáêà â ââåäåííûõ äàííûõ");
|
||||
// }
|
||||
// Dictionary<int, IMedicineModel> a = new Dictionary<int, IMedicineModel>();
|
||||
// foreach (int medicine in medicines)
|
||||
// {
|
||||
// a.Add(medicine, new AnimalSearchModel { Id = medicine } as IMedicineModel);
|
||||
// }
|
||||
[HttpPost]
|
||||
public void CreateService(string name, string price, List<int> medicines)
|
||||
{
|
||||
if (APIPharmacist.Pharmacist == null)
|
||||
{
|
||||
throw new Exception("Âû êàê ñþäà ïîïàëè? Ñþäà âõîä òîëüêî àâòîðèçîâàííûì");
|
||||
}
|
||||
StringBuilder st = new StringBuilder(price);
|
||||
for (int i = 0; i < price.Length; i++)
|
||||
{
|
||||
if (price[i] == '.')
|
||||
st[i] = ',';
|
||||
}
|
||||
price = st.ToString();
|
||||
double _price;
|
||||
try
|
||||
{
|
||||
_price = Convert.ToDouble(price);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception("Îøèáêà â ââåäåííûõ äàííûõ");
|
||||
}
|
||||
if (string.IsNullOrEmpty(name) || _price <= 0)
|
||||
{
|
||||
throw new Exception("Îøèáêà â ââåäåííûõ äàííûõ");
|
||||
}
|
||||
Dictionary<int, IMedicineModel> a = new Dictionary<int, IMedicineModel>();
|
||||
foreach (int medicine in medicines)
|
||||
{
|
||||
a.Add(medicine, new AnimalSearchModel { Id = medicine } as IMedicineModel);
|
||||
}
|
||||
|
||||
// APIPharmacist.PostRequest("api/service/createservice", new ServiceBindingModel
|
||||
// {
|
||||
// ServiceName = name,
|
||||
// Price = Math.Round(_price, 2),
|
||||
// PharmacistId = APIPharmacist.Pharmacist.Id,
|
||||
// ServiceMedicines = a
|
||||
// });
|
||||
// Response.Redirect("Index");
|
||||
//}
|
||||
APIPharmacist.PostRequest("api/service/createservice", new ServiceBindingModel
|
||||
{
|
||||
ServiceName = name,
|
||||
Price = Math.Round(_price, 2),
|
||||
PharmacistId = APIPharmacist.Pharmacist.Id,
|
||||
ServiceMedicines = a
|
||||
});
|
||||
Response.Redirect("Index");
|
||||
}
|
||||
|
||||
//public IActionResult DeleteMedicine()
|
||||
//{
|
||||
// if (APIPharmacist.Pharmacist == null)
|
||||
// {
|
||||
// return Redirect("~/Home/Enter");
|
||||
// }
|
||||
// ViewBag.Medicines = APIPharmacist.GetRequest<List<MedicineViewModel>>($"api/medicine/getmedicines?pharmacistid={APIPharmacist.Pharmacist.Id}");
|
||||
// return View();
|
||||
//}
|
||||
public IActionResult DeleteService()
|
||||
{
|
||||
if (APIPharmacist.Pharmacist == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
ViewBag.Services = APIPharmacist.GetRequest<List<ServiceViewModel>>($"api/service/getservices?pharmacistid={APIPharmacist.Pharmacist.Id}");
|
||||
return View();
|
||||
}
|
||||
|
||||
//[HttpPost]
|
||||
//public void DeleteMedicine(int medicine)
|
||||
//{
|
||||
// if (APIPharmacist.Pharmacist == null)
|
||||
// {
|
||||
// throw new Exception("Âû êàê ñþäà ïîïàëè? Ñþäà âõîä òîëüêî àâòîðèçîâàííûì");
|
||||
// }
|
||||
// APIPharmacist.PostRequest("api/medicine/deletemedicine", new MedicineBindingModel
|
||||
// {
|
||||
// Id = medicine
|
||||
// });
|
||||
// Response.Redirect("Index");
|
||||
//}
|
||||
[HttpPost]
|
||||
public void DeleteService(int service)
|
||||
{
|
||||
if (APIPharmacist.Pharmacist == null)
|
||||
{
|
||||
throw new Exception("Âû êàê ñþäà ïîïàëè? Ñþäà âõîä òîëüêî àâòîðèçîâàííûì");
|
||||
}
|
||||
APIPharmacist.PostRequest("api/service/deleteservice", new ServiceBindingModel
|
||||
{
|
||||
Id = service
|
||||
});
|
||||
Response.Redirect("Index");
|
||||
}
|
||||
|
||||
//public IActionResult UpdateMedicine()
|
||||
//{
|
||||
// if (APIPharmacist.Pharmacist == null)
|
||||
// {
|
||||
// return Redirect("~/Home/Enter");
|
||||
// }
|
||||
// ViewBag.Medicines = APIPharmacist.GetRequest<List<MedicineViewModel>>($"api/medicine/getmedicines?pharmacistid={APIPharmacist.Pharmacist.Id}");
|
||||
// ViewBag.Animals = APIPharmacist.GetRequest<List<AnimalViewModel>>($"api/animal/getanimallist");
|
||||
// return View();
|
||||
//}
|
||||
public IActionResult UpdateService()
|
||||
{
|
||||
if (APIPharmacist.Pharmacist == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
ViewBag.Services = APIPharmacist.GetRequest<List<ServiceViewModel>>($"api/service/getservices?pharmacistid={APIPharmacist.Pharmacist.Id}");
|
||||
ViewBag.Medicines = APIPharmacist.GetRequest<List<MedicineViewModel>>($"api/medicine/getmedicines");
|
||||
return View();
|
||||
}
|
||||
|
||||
//[HttpPost]
|
||||
//public void UpdateMedicine(int medicine, string name, string price,
|
||||
// List<int> animals)
|
||||
//{
|
||||
// if (APIPharmacist.Pharmacist == null)
|
||||
// {
|
||||
// throw new Exception("Âû êàê ñþäà ïîïàëè? Ñþäà âõîä òîëüêî àâòîðèçîâàííûì");
|
||||
// }
|
||||
// double _price;
|
||||
// try
|
||||
// {
|
||||
// _price = Convert.ToDouble(price);
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// throw new Exception("Îøèáêà â ââåäåííûõ äàííûõ");
|
||||
// }
|
||||
// if (string.IsNullOrEmpty(name) || _price <= 0)
|
||||
// {
|
||||
// throw new Exception("Îøèáêà â ââåäåííûõ äàííûõ");
|
||||
// }
|
||||
// Dictionary<int, IAnimalModel> a = new Dictionary<int, IAnimalModel>();
|
||||
// foreach (int animal in animals)
|
||||
// {
|
||||
// a.Add(animal, new AnimalSearchModel { Id = animal } as IAnimalModel);
|
||||
// }
|
||||
// APIPharmacist.PostRequest("api/medicine/updatemedicine", new MedicineBindingModel
|
||||
// {
|
||||
// Id = medicine,
|
||||
// MedicineName = name,
|
||||
// Price = Math.Round(_price, 2),
|
||||
// PharmacistId = APIPharmacist.Pharmacist.Id,
|
||||
// MedicineAnimals = a
|
||||
// });
|
||||
// Response.Redirect("Index");
|
||||
//}
|
||||
[HttpPost]
|
||||
public void UpdateService(int service, string name, string price,
|
||||
List<int> medicines)
|
||||
{
|
||||
if (APIPharmacist.Pharmacist == null)
|
||||
{
|
||||
throw new Exception("Âû êàê ñþäà ïîïàëè? Ñþäà âõîä òîëüêî àâòîðèçîâàííûì");
|
||||
}
|
||||
StringBuilder st = new StringBuilder(price);
|
||||
for (int i = 0; i < price.Length; i++)
|
||||
{
|
||||
if (price[i] == '.')
|
||||
st[i] = ',';
|
||||
}
|
||||
price = st.ToString();
|
||||
double _price;
|
||||
try
|
||||
{
|
||||
_price = Convert.ToDouble(price);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception("Îøèáêà â ââåäåííûõ äàííûõ");
|
||||
}
|
||||
if (string.IsNullOrEmpty(name) || _price <= 0)
|
||||
{
|
||||
throw new Exception("Îøèáêà â ââåäåííûõ äàííûõ");
|
||||
}
|
||||
Dictionary<int, IMedicineModel> a = new Dictionary<int, IMedicineModel>();
|
||||
foreach (int medicine in medicines)
|
||||
{
|
||||
a.Add(medicine, new MedicineSearchModel { Id = medicine } as IMedicineModel);
|
||||
}
|
||||
APIPharmacist.PostRequest("api/service/updateservice", new ServiceBindingModel
|
||||
{
|
||||
Id = service,
|
||||
ServiceName = name,
|
||||
Price = Math.Round(_price, 2),
|
||||
PharmacistId = APIPharmacist.Pharmacist.Id,
|
||||
ServiceMedicines = a
|
||||
});
|
||||
Response.Redirect("Index");
|
||||
}
|
||||
|
||||
//[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
|
||||
//public IActionResult Error()
|
||||
//{
|
||||
// return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
|
||||
//}
|
||||
[HttpGet]
|
||||
public Tuple<ServiceViewModel, List<string>>? GetService(int serviceId)
|
||||
{
|
||||
if (APIPharmacist.Pharmacist == null)
|
||||
{
|
||||
throw new Exception("Âû êàê ñþäà ïîïàëè? Ñþäà âõîä òîëüêî àâòîðèçîâàííûì");
|
||||
}
|
||||
var result = APIPharmacist.GetRequest<Tuple<ServiceViewModel, List<string>>>($"api/service/getservice?serviceid={serviceId}");
|
||||
if (result == null)
|
||||
{
|
||||
return default;
|
||||
}
|
||||
|
||||
//[HttpGet]
|
||||
//public Tuple<MedicineViewModel, List<string>>? GetMedicine(int medicineId)
|
||||
//{
|
||||
// if (APIPharmacist.Pharmacist == null)
|
||||
// {
|
||||
// throw new Exception("Âû êàê ñþäà ïîïàëè? Ñþäà âõîä òîëüêî àâòîðèçîâàííûì");
|
||||
// }
|
||||
// var result = APIPharmacist.GetRequest<Tuple<MedicineViewModel, List<string>>>($"api/medicine/getmedicine?medicineid={medicineId}");
|
||||
// if (result == null)
|
||||
// {
|
||||
// return default;
|
||||
// }
|
||||
|
||||
// return result;
|
||||
//}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
39
VetClinic/PharmacistApp/Views/Home/CreateService.cshtml
Normal file
39
VetClinic/PharmacistApp/Views/Home/CreateService.cshtml
Normal file
@ -0,0 +1,39 @@
|
||||
@{
|
||||
ViewData["Title"] = "CreateService";
|
||||
}
|
||||
|
||||
<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="name" id="name" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Цена:</div>
|
||||
<div class="col-8">
|
||||
<input type="text" name="price" id="price" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Медикаменты:</div>
|
||||
<div class="col-8">
|
||||
<select name="medicines" class="form-control" multiple size="6" id="medicines">
|
||||
@foreach (var medicine in ViewBag.Medicines)
|
||||
{
|
||||
<option value="@medicine.Id">@medicine.MedicineName</option>
|
||||
}
|
||||
</select>
|
||||
</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>
|
@ -1,5 +1,5 @@
|
||||
@{
|
||||
ViewData["Title"] = "Delete";
|
||||
ViewData["Title"] = "DeleteMedicine";
|
||||
}
|
||||
<div class="text-center">
|
||||
<h2 class="display-4">Удаление медикамента</h2>
|
||||
|
18
VetClinic/PharmacistApp/Views/Home/DeleteService.cshtml
Normal file
18
VetClinic/PharmacistApp/Views/Home/DeleteService.cshtml
Normal file
@ -0,0 +1,18 @@
|
||||
@{
|
||||
ViewData["Title"] = "DeleteService";
|
||||
}
|
||||
<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="service" name="service" class="form-control" asp-items="@(new SelectList(@ViewBag.Services, "Id", "ServiceName"))"></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>s
|
56
VetClinic/PharmacistApp/Views/Home/Services.cshtml
Normal file
56
VetClinic/PharmacistApp/Views/Home/Services.cshtml
Normal file
@ -0,0 +1,56 @@
|
||||
@using VetClinicContracts.ViewModels
|
||||
@model List<ServiceViewModel>
|
||||
@{
|
||||
ViewData["Title"] = "Services";
|
||||
}
|
||||
<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="CreateService">Создать услугу</a>
|
||||
<a asp-action="UpdateService">Обновить услугу</a>
|
||||
<a asp-action="DeleteService">Удалить услугу</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.ServiceName)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem =>
|
||||
item.Price)
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
}
|
||||
</div>
|
71
VetClinic/PharmacistApp/Views/Home/UpdateService.cshtml
Normal file
71
VetClinic/PharmacistApp/Views/Home/UpdateService.cshtml
Normal file
@ -0,0 +1,71 @@
|
||||
@using VetClinicContracts.ViewModels;
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "UpdateService";
|
||||
}
|
||||
|
||||
<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="service" name="service" class="form-control" asp-items="@(new SelectList(@ViewBag.Services, "Id", "ServiceName"))"></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="price" name="price" class="form-control" /></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Медикаменты:</div>
|
||||
<div class="col-8">
|
||||
<select name="medicines" class="form-control" multiple size="5" id="medicines">
|
||||
@foreach (var medicine in ViewBag.Medicines)
|
||||
{
|
||||
<option value="@medicine.Id" id="@medicine.MedicineName">@medicine.MedicineName</option>
|
||||
}
|
||||
</select>
|
||||
</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 service = $('#service').val();
|
||||
$("#medicines option:selected").removeAttr("selected");
|
||||
if (service) {
|
||||
$.ajax({
|
||||
method: "GET",
|
||||
url: "/Home/GetService",
|
||||
data: { serviceId: service },
|
||||
success: function (result) {
|
||||
console.log(result.item2);
|
||||
$('#name').val(result.item1.serviceName);
|
||||
$('#price').val(result.item1.price);
|
||||
$.map(result.item2, function ( n ) {
|
||||
console.log("#" + n);
|
||||
$("#" + n).attr("selected", "selected")
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
};
|
||||
}
|
||||
check();
|
||||
$('#service').on('change', function () {
|
||||
check();
|
||||
});
|
||||
</script>
|
||||
}
|
@ -23,6 +23,9 @@
|
||||
<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="Services">Услуги</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="Privacy">Личные данные</a>
|
||||
</li>
|
||||
|
@ -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; }
|
||||
}
|
||||
}
|
||||
|
515
VetClinic/VetClinicDataBaseImplement/Migrations/20240428120220_InitialCreate.Designer.cs
generated
Normal file
515
VetClinic/VetClinicDataBaseImplement/Migrations/20240428120220_InitialCreate.Designer.cs
generated
Normal file
@ -0,0 +1,515 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using VetClinicDataBaseImplement;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace VetClinicDataBaseImplement.Migrations
|
||||
{
|
||||
[DbContext(typeof(VetClinicDatabase))]
|
||||
[Migration("20240428120220_InitialCreate")]
|
||||
partial class InitialCreate
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "8.0.4")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||
|
||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("VetClinicDataBaseImplement.Models.Admin", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("AdminFIO")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Email")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Password")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Admins");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VetClinicDataBaseImplement.Models.Animal", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("AdminId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("AnimalName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Family")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("AdminId");
|
||||
|
||||
b.ToTable("Animals");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VetClinicDataBaseImplement.Models.Guidance", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<DateTime>("Date")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<int>("ServiceId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("Text")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ServiceId");
|
||||
|
||||
b.ToTable("Guidances");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VetClinicDataBaseImplement.Models.Medicine", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("MedicineName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int>("PharmacistId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<double>("Price")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("PharmacistId");
|
||||
|
||||
b.ToTable("Medicines");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VetClinicDataBaseImplement.Models.MedicineAnimal", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("AnimalId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("MedicineId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("AnimalId");
|
||||
|
||||
b.HasIndex("MedicineId");
|
||||
|
||||
b.ToTable("MedicineAnimals");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VetClinicDataBaseImplement.Models.Pharmacist", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Email")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Password")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("PharmacistFIO")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Pharmacists");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VetClinicDataBaseImplement.Models.Service", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("PharmacistId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<double>("Price")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.Property<string>("ServiceName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("PharmacistId");
|
||||
|
||||
b.ToTable("Services");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VetClinicDataBaseImplement.Models.ServiceMedicine", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("MedicineId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("ServiceId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("MedicineId");
|
||||
|
||||
b.HasIndex("ServiceId");
|
||||
|
||||
b.ToTable("ServiceMedicines");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VetClinicDataBaseImplement.Models.Vaccination", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("AnimalId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<double>("CostVaccination")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.Property<DateTime?>("DateStamp")
|
||||
.IsRequired()
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<string>("NameVaccination")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("AnimalId");
|
||||
|
||||
b.ToTable("Vaccinations");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VetClinicDataBaseImplement.Models.Visit", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("AdminId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime>("DateVisit")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<string>("NameVisit")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("AdminId");
|
||||
|
||||
b.ToTable("Visits");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VetClinicDataBaseImplement.Models.VisitAnimal", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("AnimalId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("VisitId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("AnimalId");
|
||||
|
||||
b.HasIndex("VisitId");
|
||||
|
||||
b.ToTable("VisitAnimals");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VetClinicDataBaseImplement.Models.VisitService", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("ServiceId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("VisitId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ServiceId");
|
||||
|
||||
b.HasIndex("VisitId");
|
||||
|
||||
b.ToTable("ServiceVisits");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VetClinicDataBaseImplement.Models.Animal", b =>
|
||||
{
|
||||
b.HasOne("VetClinicDataBaseImplement.Models.Admin", "Admin")
|
||||
.WithMany("Animals")
|
||||
.HasForeignKey("AdminId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Admin");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VetClinicDataBaseImplement.Models.Guidance", b =>
|
||||
{
|
||||
b.HasOne("VetClinicDataBaseImplement.Models.Service", "Service")
|
||||
.WithMany("Guidances")
|
||||
.HasForeignKey("ServiceId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Service");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VetClinicDataBaseImplement.Models.Medicine", b =>
|
||||
{
|
||||
b.HasOne("VetClinicDataBaseImplement.Models.Pharmacist", "Pharmacist")
|
||||
.WithMany("Medicines")
|
||||
.HasForeignKey("PharmacistId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Pharmacist");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VetClinicDataBaseImplement.Models.MedicineAnimal", b =>
|
||||
{
|
||||
b.HasOne("VetClinicDataBaseImplement.Models.Animal", "Animal")
|
||||
.WithMany("Medicines")
|
||||
.HasForeignKey("AnimalId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("VetClinicDataBaseImplement.Models.Medicine", "Medicine")
|
||||
.WithMany("Animals")
|
||||
.HasForeignKey("MedicineId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Animal");
|
||||
|
||||
b.Navigation("Medicine");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VetClinicDataBaseImplement.Models.Service", b =>
|
||||
{
|
||||
b.HasOne("VetClinicDataBaseImplement.Models.Pharmacist", "Pharmacist")
|
||||
.WithMany("Services")
|
||||
.HasForeignKey("PharmacistId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Pharmacist");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VetClinicDataBaseImplement.Models.ServiceMedicine", b =>
|
||||
{
|
||||
b.HasOne("VetClinicDataBaseImplement.Models.Medicine", "Medicine")
|
||||
.WithMany("Services")
|
||||
.HasForeignKey("MedicineId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("VetClinicDataBaseImplement.Models.Service", "Service")
|
||||
.WithMany("Medicines")
|
||||
.HasForeignKey("ServiceId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Medicine");
|
||||
|
||||
b.Navigation("Service");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VetClinicDataBaseImplement.Models.Vaccination", b =>
|
||||
{
|
||||
b.HasOne("VetClinicDataBaseImplement.Models.Animal", "Animal")
|
||||
.WithMany("Vaccinations")
|
||||
.HasForeignKey("AnimalId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Animal");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VetClinicDataBaseImplement.Models.Visit", b =>
|
||||
{
|
||||
b.HasOne("VetClinicDataBaseImplement.Models.Admin", "Admin")
|
||||
.WithMany("Visits")
|
||||
.HasForeignKey("AdminId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Admin");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VetClinicDataBaseImplement.Models.VisitAnimal", b =>
|
||||
{
|
||||
b.HasOne("VetClinicDataBaseImplement.Models.Animal", "Animal")
|
||||
.WithMany("Visits")
|
||||
.HasForeignKey("AnimalId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("VetClinicDataBaseImplement.Models.Visit", "Visit")
|
||||
.WithMany("Animals")
|
||||
.HasForeignKey("VisitId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Animal");
|
||||
|
||||
b.Navigation("Visit");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VetClinicDataBaseImplement.Models.VisitService", b =>
|
||||
{
|
||||
b.HasOne("VetClinicDataBaseImplement.Models.Service", "Service")
|
||||
.WithMany("Visits")
|
||||
.HasForeignKey("ServiceId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("VetClinicDataBaseImplement.Models.Visit", "Visit")
|
||||
.WithMany("Services")
|
||||
.HasForeignKey("VisitId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Service");
|
||||
|
||||
b.Navigation("Visit");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VetClinicDataBaseImplement.Models.Admin", b =>
|
||||
{
|
||||
b.Navigation("Animals");
|
||||
|
||||
b.Navigation("Visits");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VetClinicDataBaseImplement.Models.Animal", b =>
|
||||
{
|
||||
b.Navigation("Medicines");
|
||||
|
||||
b.Navigation("Vaccinations");
|
||||
|
||||
b.Navigation("Visits");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VetClinicDataBaseImplement.Models.Medicine", b =>
|
||||
{
|
||||
b.Navigation("Animals");
|
||||
|
||||
b.Navigation("Services");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VetClinicDataBaseImplement.Models.Pharmacist", b =>
|
||||
{
|
||||
b.Navigation("Medicines");
|
||||
|
||||
b.Navigation("Services");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VetClinicDataBaseImplement.Models.Service", b =>
|
||||
{
|
||||
b.Navigation("Guidances");
|
||||
|
||||
b.Navigation("Medicines");
|
||||
|
||||
b.Navigation("Visits");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VetClinicDataBaseImplement.Models.Visit", b =>
|
||||
{
|
||||
b.Navigation("Animals");
|
||||
|
||||
b.Navigation("Services");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,386 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace VetClinicDataBaseImplement.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class InitialCreate : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Admins",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
AdminFIO = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Email = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Password = table.Column<string>(type: "nvarchar(max)", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Admins", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Pharmacists",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
PharmacistFIO = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Email = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Password = table.Column<string>(type: "nvarchar(max)", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Pharmacists", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Animals",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
AdminId = table.Column<int>(type: "int", nullable: false),
|
||||
AnimalName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Family = table.Column<string>(type: "nvarchar(max)", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Animals", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Animals_Admins_AdminId",
|
||||
column: x => x.AdminId,
|
||||
principalTable: "Admins",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Visits",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
AdminId = table.Column<int>(type: "int", nullable: false),
|
||||
NameVisit = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
DateVisit = table.Column<DateTime>(type: "datetime2", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Visits", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Visits_Admins_AdminId",
|
||||
column: x => x.AdminId,
|
||||
principalTable: "Admins",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Medicines",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
MedicineName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
PharmacistId = table.Column<int>(type: "int", nullable: false),
|
||||
Price = table.Column<double>(type: "float", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Medicines", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Medicines_Pharmacists_PharmacistId",
|
||||
column: x => x.PharmacistId,
|
||||
principalTable: "Pharmacists",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Services",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
ServiceName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Price = table.Column<double>(type: "float", nullable: false),
|
||||
PharmacistId = table.Column<int>(type: "int", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Services", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Services_Pharmacists_PharmacistId",
|
||||
column: x => x.PharmacistId,
|
||||
principalTable: "Pharmacists",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Vaccinations",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
AnimalId = table.Column<int>(type: "int", nullable: false),
|
||||
NameVaccination = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
CostVaccination = table.Column<double>(type: "float", nullable: false),
|
||||
DateStamp = table.Column<DateTime>(type: "datetime2", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Vaccinations", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Vaccinations_Animals_AnimalId",
|
||||
column: x => x.AnimalId,
|
||||
principalTable: "Animals",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "VisitAnimals",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
AnimalId = table.Column<int>(type: "int", nullable: false),
|
||||
VisitId = table.Column<int>(type: "int", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_VisitAnimals", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_VisitAnimals_Animals_AnimalId",
|
||||
column: x => x.AnimalId,
|
||||
principalTable: "Animals",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_VisitAnimals_Visits_VisitId",
|
||||
column: x => x.VisitId,
|
||||
principalTable: "Visits",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "MedicineAnimals",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
MedicineId = table.Column<int>(type: "int", nullable: false),
|
||||
AnimalId = table.Column<int>(type: "int", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_MedicineAnimals", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_MedicineAnimals_Animals_AnimalId",
|
||||
column: x => x.AnimalId,
|
||||
principalTable: "Animals",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_MedicineAnimals_Medicines_MedicineId",
|
||||
column: x => x.MedicineId,
|
||||
principalTable: "Medicines",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Guidances",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
ServiceId = table.Column<int>(type: "int", nullable: false),
|
||||
Text = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Date = table.Column<DateTime>(type: "datetime2", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Guidances", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Guidances_Services_ServiceId",
|
||||
column: x => x.ServiceId,
|
||||
principalTable: "Services",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "ServiceMedicines",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
ServiceId = table.Column<int>(type: "int", nullable: false),
|
||||
MedicineId = table.Column<int>(type: "int", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_ServiceMedicines", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_ServiceMedicines_Medicines_MedicineId",
|
||||
column: x => x.MedicineId,
|
||||
principalTable: "Medicines",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_ServiceMedicines_Services_ServiceId",
|
||||
column: x => x.ServiceId,
|
||||
principalTable: "Services",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "ServiceVisits",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
ServiceId = table.Column<int>(type: "int", nullable: false),
|
||||
VisitId = table.Column<int>(type: "int", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_ServiceVisits", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_ServiceVisits_Services_ServiceId",
|
||||
column: x => x.ServiceId,
|
||||
principalTable: "Services",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_ServiceVisits_Visits_VisitId",
|
||||
column: x => x.VisitId,
|
||||
principalTable: "Visits",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Animals_AdminId",
|
||||
table: "Animals",
|
||||
column: "AdminId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Guidances_ServiceId",
|
||||
table: "Guidances",
|
||||
column: "ServiceId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_MedicineAnimals_AnimalId",
|
||||
table: "MedicineAnimals",
|
||||
column: "AnimalId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_MedicineAnimals_MedicineId",
|
||||
table: "MedicineAnimals",
|
||||
column: "MedicineId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Medicines_PharmacistId",
|
||||
table: "Medicines",
|
||||
column: "PharmacistId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ServiceMedicines_MedicineId",
|
||||
table: "ServiceMedicines",
|
||||
column: "MedicineId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ServiceMedicines_ServiceId",
|
||||
table: "ServiceMedicines",
|
||||
column: "ServiceId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Services_PharmacistId",
|
||||
table: "Services",
|
||||
column: "PharmacistId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ServiceVisits_ServiceId",
|
||||
table: "ServiceVisits",
|
||||
column: "ServiceId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ServiceVisits_VisitId",
|
||||
table: "ServiceVisits",
|
||||
column: "VisitId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Vaccinations_AnimalId",
|
||||
table: "Vaccinations",
|
||||
column: "AnimalId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_VisitAnimals_AnimalId",
|
||||
table: "VisitAnimals",
|
||||
column: "AnimalId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_VisitAnimals_VisitId",
|
||||
table: "VisitAnimals",
|
||||
column: "VisitId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Visits_AdminId",
|
||||
table: "Visits",
|
||||
column: "AdminId");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "Guidances");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "MedicineAnimals");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "ServiceMedicines");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "ServiceVisits");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Vaccinations");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "VisitAnimals");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Medicines");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Services");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Animals");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Visits");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Pharmacists");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Admins");
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,512 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using VetClinicDataBaseImplement;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace VetClinicDataBaseImplement.Migrations
|
||||
{
|
||||
[DbContext(typeof(VetClinicDatabase))]
|
||||
partial class VetClinicDatabaseModelSnapshot : ModelSnapshot
|
||||
{
|
||||
protected override void BuildModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "8.0.4")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||
|
||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("VetClinicDataBaseImplement.Models.Admin", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("AdminFIO")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Email")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Password")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Admins");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VetClinicDataBaseImplement.Models.Animal", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("AdminId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("AnimalName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Family")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("AdminId");
|
||||
|
||||
b.ToTable("Animals");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VetClinicDataBaseImplement.Models.Guidance", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<DateTime>("Date")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<int>("ServiceId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("Text")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ServiceId");
|
||||
|
||||
b.ToTable("Guidances");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VetClinicDataBaseImplement.Models.Medicine", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("MedicineName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int>("PharmacistId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<double>("Price")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("PharmacistId");
|
||||
|
||||
b.ToTable("Medicines");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VetClinicDataBaseImplement.Models.MedicineAnimal", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("AnimalId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("MedicineId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("AnimalId");
|
||||
|
||||
b.HasIndex("MedicineId");
|
||||
|
||||
b.ToTable("MedicineAnimals");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VetClinicDataBaseImplement.Models.Pharmacist", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Email")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Password")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("PharmacistFIO")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Pharmacists");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VetClinicDataBaseImplement.Models.Service", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("PharmacistId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<double>("Price")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.Property<string>("ServiceName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("PharmacistId");
|
||||
|
||||
b.ToTable("Services");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VetClinicDataBaseImplement.Models.ServiceMedicine", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("MedicineId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("ServiceId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("MedicineId");
|
||||
|
||||
b.HasIndex("ServiceId");
|
||||
|
||||
b.ToTable("ServiceMedicines");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VetClinicDataBaseImplement.Models.Vaccination", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("AnimalId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<double>("CostVaccination")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.Property<DateTime?>("DateStamp")
|
||||
.IsRequired()
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<string>("NameVaccination")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("AnimalId");
|
||||
|
||||
b.ToTable("Vaccinations");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VetClinicDataBaseImplement.Models.Visit", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("AdminId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime>("DateVisit")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<string>("NameVisit")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("AdminId");
|
||||
|
||||
b.ToTable("Visits");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VetClinicDataBaseImplement.Models.VisitAnimal", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("AnimalId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("VisitId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("AnimalId");
|
||||
|
||||
b.HasIndex("VisitId");
|
||||
|
||||
b.ToTable("VisitAnimals");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VetClinicDataBaseImplement.Models.VisitService", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("ServiceId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("VisitId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ServiceId");
|
||||
|
||||
b.HasIndex("VisitId");
|
||||
|
||||
b.ToTable("ServiceVisits");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VetClinicDataBaseImplement.Models.Animal", b =>
|
||||
{
|
||||
b.HasOne("VetClinicDataBaseImplement.Models.Admin", "Admin")
|
||||
.WithMany("Animals")
|
||||
.HasForeignKey("AdminId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Admin");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VetClinicDataBaseImplement.Models.Guidance", b =>
|
||||
{
|
||||
b.HasOne("VetClinicDataBaseImplement.Models.Service", "Service")
|
||||
.WithMany("Guidances")
|
||||
.HasForeignKey("ServiceId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Service");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VetClinicDataBaseImplement.Models.Medicine", b =>
|
||||
{
|
||||
b.HasOne("VetClinicDataBaseImplement.Models.Pharmacist", "Pharmacist")
|
||||
.WithMany("Medicines")
|
||||
.HasForeignKey("PharmacistId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Pharmacist");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VetClinicDataBaseImplement.Models.MedicineAnimal", b =>
|
||||
{
|
||||
b.HasOne("VetClinicDataBaseImplement.Models.Animal", "Animal")
|
||||
.WithMany("Medicines")
|
||||
.HasForeignKey("AnimalId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("VetClinicDataBaseImplement.Models.Medicine", "Medicine")
|
||||
.WithMany("Animals")
|
||||
.HasForeignKey("MedicineId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Animal");
|
||||
|
||||
b.Navigation("Medicine");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VetClinicDataBaseImplement.Models.Service", b =>
|
||||
{
|
||||
b.HasOne("VetClinicDataBaseImplement.Models.Pharmacist", "Pharmacist")
|
||||
.WithMany("Services")
|
||||
.HasForeignKey("PharmacistId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Pharmacist");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VetClinicDataBaseImplement.Models.ServiceMedicine", b =>
|
||||
{
|
||||
b.HasOne("VetClinicDataBaseImplement.Models.Medicine", "Medicine")
|
||||
.WithMany("Services")
|
||||
.HasForeignKey("MedicineId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("VetClinicDataBaseImplement.Models.Service", "Service")
|
||||
.WithMany("Medicines")
|
||||
.HasForeignKey("ServiceId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Medicine");
|
||||
|
||||
b.Navigation("Service");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VetClinicDataBaseImplement.Models.Vaccination", b =>
|
||||
{
|
||||
b.HasOne("VetClinicDataBaseImplement.Models.Animal", "Animal")
|
||||
.WithMany("Vaccinations")
|
||||
.HasForeignKey("AnimalId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Animal");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VetClinicDataBaseImplement.Models.Visit", b =>
|
||||
{
|
||||
b.HasOne("VetClinicDataBaseImplement.Models.Admin", "Admin")
|
||||
.WithMany("Visits")
|
||||
.HasForeignKey("AdminId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Admin");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VetClinicDataBaseImplement.Models.VisitAnimal", b =>
|
||||
{
|
||||
b.HasOne("VetClinicDataBaseImplement.Models.Animal", "Animal")
|
||||
.WithMany("Visits")
|
||||
.HasForeignKey("AnimalId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("VetClinicDataBaseImplement.Models.Visit", "Visit")
|
||||
.WithMany("Animals")
|
||||
.HasForeignKey("VisitId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Animal");
|
||||
|
||||
b.Navigation("Visit");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VetClinicDataBaseImplement.Models.VisitService", b =>
|
||||
{
|
||||
b.HasOne("VetClinicDataBaseImplement.Models.Service", "Service")
|
||||
.WithMany("Visits")
|
||||
.HasForeignKey("ServiceId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("VetClinicDataBaseImplement.Models.Visit", "Visit")
|
||||
.WithMany("Services")
|
||||
.HasForeignKey("VisitId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Service");
|
||||
|
||||
b.Navigation("Visit");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VetClinicDataBaseImplement.Models.Admin", b =>
|
||||
{
|
||||
b.Navigation("Animals");
|
||||
|
||||
b.Navigation("Visits");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VetClinicDataBaseImplement.Models.Animal", b =>
|
||||
{
|
||||
b.Navigation("Medicines");
|
||||
|
||||
b.Navigation("Vaccinations");
|
||||
|
||||
b.Navigation("Visits");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VetClinicDataBaseImplement.Models.Medicine", b =>
|
||||
{
|
||||
b.Navigation("Animals");
|
||||
|
||||
b.Navigation("Services");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VetClinicDataBaseImplement.Models.Pharmacist", b =>
|
||||
{
|
||||
b.Navigation("Medicines");
|
||||
|
||||
b.Navigation("Services");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VetClinicDataBaseImplement.Models.Service", b =>
|
||||
{
|
||||
b.Navigation("Guidances");
|
||||
|
||||
b.Navigation("Medicines");
|
||||
|
||||
b.Navigation("Visits");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VetClinicDataBaseImplement.Models.Visit", b =>
|
||||
{
|
||||
b.Navigation("Animals");
|
||||
|
||||
b.Navigation("Services");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
@ -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)
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -52,6 +52,8 @@ namespace VetClinicDataBaseImplement.Models
|
||||
Id = model.Id,
|
||||
ServiceName = model.ServiceName,
|
||||
Price = model.Price,
|
||||
PharmacistId = model.PharmacistId,
|
||||
Pharmacist = context.Pharmacists.First(x => x.Id == model.PharmacistId),
|
||||
Medicines = model.ServiceMedicines.Select(x => new
|
||||
ServiceMedicine
|
||||
{
|
||||
|
@ -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; }
|
||||
}
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ namespace VetClinicRestApi.Controllers
|
||||
if (elem == null)
|
||||
return null;
|
||||
var res = Tuple.Create(elem, elem.MedicineAnimals.Select(x => x.Value.AnimalName).ToList());
|
||||
res.Item1.MedicineAnimals = null;
|
||||
res.Item1.MedicineAnimals = null!;
|
||||
return res;
|
||||
}
|
||||
catch (Exception ex)
|
||||
@ -38,7 +38,7 @@ namespace VetClinicRestApi.Controllers
|
||||
}
|
||||
}
|
||||
[HttpGet]
|
||||
public List<MedicineViewModel>? GetMedicines(int pharmacistId)
|
||||
public List<MedicineViewModel>? GetMedicines(int? pharmacistId = null)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -4,6 +4,7 @@ using VetClinicContracts.BindingModels;
|
||||
using VetClinicContracts.BusinessLogicsContracts;
|
||||
using VetClinicContracts.SearchModels;
|
||||
using VetClinicContracts.ViewModels;
|
||||
using VetClinicDataBaseImplement.Models;
|
||||
|
||||
namespace VetClinicRestApi.Controllers
|
||||
{
|
||||
@ -27,7 +28,9 @@ namespace VetClinicRestApi.Controllers
|
||||
var elem = _service.ReadElement(new ServiceSearchModel { Id = serviceId });
|
||||
if (elem == null)
|
||||
return null;
|
||||
return Tuple.Create(elem, elem.ServiceMedicines.Select(x => x.Value.MedicineName).ToList());
|
||||
var res = Tuple.Create(elem, elem.ServiceMedicines.Select(x => x.Value.MedicineName).ToList());
|
||||
res.Item1.ServiceMedicines = null!;
|
||||
return res;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@ -36,11 +39,14 @@ namespace VetClinicRestApi.Controllers
|
||||
}
|
||||
}
|
||||
[HttpGet]
|
||||
public List<ServiceViewModel> GetServices(int pharmacistId)
|
||||
public List<ServiceViewModel> GetServices(int? pharmacistId = null)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _service.ReadList(new ServiceSearchModel { PharmacistId = pharmacistId });
|
||||
var res = _service.ReadList(new ServiceSearchModel { PharmacistId = pharmacistId });
|
||||
foreach (var service in res)
|
||||
service.ServiceMedicines = null;
|
||||
return res;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@ -67,7 +73,6 @@ namespace VetClinicRestApi.Controllers
|
||||
{
|
||||
try
|
||||
{
|
||||
model.ServiceMedicines = null!;
|
||||
return _service.Update(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
@ -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