Compare commits
13 Commits
cde48f8eef
...
18ba6200b3
Author | SHA1 | Date | |
---|---|---|---|
18ba6200b3 | |||
|
48f2eb83b4 | ||
|
c6a72b65b7 | ||
|
77484409f6 | ||
|
51b0308ea8 | ||
0728fb599c | |||
|
7214604c67 | ||
|
f6c25cf968 | ||
|
ea42dc9fc4 | ||
|
1ff125d5a9 | ||
|
8003d8f7f9 | ||
|
ea299b652d | ||
|
7d8ea70e32 |
@ -1,7 +1,10 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using NPOI.SS.UserModel;
|
||||
using PharmacistApp.Models;
|
||||
using System.Diagnostics;
|
||||
using System.Text;
|
||||
using VetClinicContracts.BindingModels;
|
||||
using VetClinicContracts.SearchModels;
|
||||
using VetClinicContracts.ViewModels;
|
||||
using VetClinicDataBaseImplement.Models;
|
||||
using VetClinicDataModels.Models;
|
||||
@ -44,12 +47,12 @@ View(APIPharmacist.GetRequest<List<MedicineViewModel>>($"api/medicine/getmedicin
|
||||
{
|
||||
if (APIPharmacist.Pharmacist == null)
|
||||
{
|
||||
throw new Exception("Âû êàê ñóäà ïîïàëè? Ñóäà âõîä òîëüêî àâòîðèçîâàííûì");
|
||||
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
|
||||
}
|
||||
if (string.IsNullOrEmpty(email) ||
|
||||
string.IsNullOrEmpty(password) || string.IsNullOrEmpty(fio))
|
||||
{
|
||||
throw new Exception("Ââåäèòå email, ïàðîëü è ÔÈÎ");
|
||||
throw new Exception("Введите email, пароль и ФИО");
|
||||
}
|
||||
APIPharmacist.PostRequest("api/pharmacist/updatedata", new
|
||||
PharmacistBindingModel
|
||||
@ -76,13 +79,13 @@ View(APIPharmacist.GetRequest<List<MedicineViewModel>>($"api/medicine/getmedicin
|
||||
if (string.IsNullOrEmpty(email) ||
|
||||
string.IsNullOrEmpty(password))
|
||||
{
|
||||
throw new Exception("Ââåäèòå email è ïàðîëü");
|
||||
throw new Exception("Введите email и пароль");
|
||||
}
|
||||
APIPharmacist.Pharmacist =
|
||||
APIPharmacist.GetRequest<PharmacistViewModel>($"api/pharmacist/login?email={email}&password={password}");
|
||||
if (APIPharmacist.Pharmacist == null)
|
||||
{
|
||||
throw new Exception("Íåâåðíûé ëîãèí/ïàðîëü");
|
||||
throw new Exception("Неверный логин/пароль");
|
||||
}
|
||||
Response.Redirect("Index");
|
||||
}
|
||||
@ -97,7 +100,7 @@ View(APIPharmacist.GetRequest<List<MedicineViewModel>>($"api/medicine/getmedicin
|
||||
if (string.IsNullOrEmpty(email) ||
|
||||
string.IsNullOrEmpty(password) || string.IsNullOrEmpty(fio))
|
||||
{
|
||||
throw new Exception("Ââåäèòå ëîãèí, ïàðîëü è ÔÈÎ");
|
||||
throw new Exception("Введите логин, пароль и ФИО");
|
||||
}
|
||||
APIPharmacist.PostRequest("api/pharmacist/register", new
|
||||
PharmacistBindingModel
|
||||
@ -122,20 +125,37 @@ View(APIPharmacist.GetRequest<List<MedicineViewModel>>($"api/medicine/getmedicin
|
||||
|
||||
|
||||
[HttpPost]
|
||||
public void CreateMedicine(string name, int price)
|
||||
public void CreateMedicine(string name, string price)
|
||||
{
|
||||
if (APIPharmacist.Pharmacist == null)
|
||||
{
|
||||
throw new Exception("Âû êàê ñþäà ïîïàëè? Ñþäà âõîä òîëüêî àâòîðèçîâàííûì");
|
||||
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
|
||||
}
|
||||
if (string.IsNullOrEmpty(name) || price <= 0)
|
||||
StringBuilder st = new StringBuilder(price);
|
||||
for (int i = 0; i < price.Length; i++)
|
||||
{
|
||||
throw new Exception("Îøèáêà â ââåäåííûõ äàííûõ");
|
||||
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("Ошибка в введенных данных");
|
||||
}
|
||||
|
||||
APIPharmacist.PostRequest("api/medicine/createmedicine", new MedicineBindingModel
|
||||
{
|
||||
MedicineName = name,
|
||||
Price = price,
|
||||
Price = Math.Round(_price, 2),
|
||||
PharmacistId = APIPharmacist.Pharmacist.Id
|
||||
}) ;
|
||||
Response.Redirect("Index");
|
||||
@ -156,7 +176,7 @@ View(APIPharmacist.GetRequest<List<MedicineViewModel>>($"api/medicine/getmedicin
|
||||
{
|
||||
if (APIPharmacist.Pharmacist == null)
|
||||
{
|
||||
throw new Exception("Âû êàê ñþäà ïîïàëè? Ñþäà âõîä òîëüêî àâòîðèçîâàííûì");
|
||||
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
|
||||
}
|
||||
APIPharmacist.PostRequest("api/medicine/deletemedicine", new MedicineBindingModel
|
||||
{
|
||||
@ -176,24 +196,94 @@ View(APIPharmacist.GetRequest<List<MedicineViewModel>>($"api/medicine/getmedicin
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void UpdateMedicine(int medicine, string name, int price,
|
||||
Dictionary<int, IAnimalModel> medicineAnimals = null)
|
||||
public void UpdateMedicine(int medicine, string name, string price)
|
||||
{
|
||||
if (APIPharmacist.Pharmacist == null)
|
||||
{
|
||||
throw new Exception("Âû êàê ñþäà ïîïàëè? Ñþäà âõîä òîëüêî àâòîðèçîâàííûì");
|
||||
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
|
||||
}
|
||||
if (string.IsNullOrEmpty(name) || price <= 0)
|
||||
StringBuilder st = new StringBuilder(price);
|
||||
for (int i = 0; i < price.Length; i++)
|
||||
{
|
||||
throw new Exception("Îøèáêà â ââåäåííûõ äàííûõ");
|
||||
if (price[i] == '.')
|
||||
st[i] = ',';
|
||||
}
|
||||
APIPharmacist.PostRequest("api/medicine/updatemedicine", new MedicineBindingModel
|
||||
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("Ошибка в введенных данных");
|
||||
}
|
||||
APIPharmacist.PostRequest("api/medicine/updatemedicine?isconnection=false", new MedicineBindingModel
|
||||
{
|
||||
Id = medicine,
|
||||
MedicineName = name,
|
||||
Price = price,
|
||||
Price = Math.Round(_price, 2),
|
||||
PharmacistId = APIPharmacist.Pharmacist.Id,
|
||||
MedicineAnimals = medicineAnimals
|
||||
});
|
||||
Response.Redirect("Index");
|
||||
}
|
||||
|
||||
public IActionResult MedicineAnimals()
|
||||
{
|
||||
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();
|
||||
}
|
||||
|
||||
|
||||
[HttpPost]
|
||||
public void MedicineAnimals(int medicine, string name, string price,
|
||||
List<int> animals)
|
||||
{
|
||||
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, 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?isconnection=true", new MedicineBindingModel
|
||||
{
|
||||
Id = medicine,
|
||||
MedicineName = name,
|
||||
Price = Math.Round(_price, 2),
|
||||
PharmacistId = APIPharmacist.Pharmacist.Id,
|
||||
MedicineAnimals = a
|
||||
});
|
||||
Response.Redirect("Index");
|
||||
}
|
||||
@ -205,27 +295,19 @@ View(APIPharmacist.GetRequest<List<MedicineViewModel>>($"api/medicine/getmedicin
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public Tuple<MedicineViewModel, string>? GetMedicine(int medicineId)
|
||||
public Tuple<MedicineViewModel, List<string>>? GetMedicine(int medicineId)
|
||||
{
|
||||
if (APIPharmacist.Pharmacist == null)
|
||||
{
|
||||
throw new Exception("Âû êàê ñþäà ïîïàëè? Ñþäà âõîä òîëüêî àâòîðèçîâàííûì");
|
||||
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
|
||||
}
|
||||
var result = APIPharmacist.GetRequest<Tuple<MedicineViewModel, List<string>>>($"api/medicine/getmedicine?medicineid={medicineId}");
|
||||
if (result == null)
|
||||
{
|
||||
return default;
|
||||
}
|
||||
string table = "";
|
||||
result.Item1.MedicineAnimals.Clear();
|
||||
for (int i = 0; i < result.Item2.Count; i++)
|
||||
{
|
||||
var animal = result.Item2[i];
|
||||
table += "<tr>";
|
||||
table += $"<td>{animal}</td>";
|
||||
table += "</tr>";
|
||||
}
|
||||
return Tuple.Create(result.Item1, table);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
@ -233,10 +315,154 @@ View(APIPharmacist.GetRequest<List<MedicineViewModel>>($"api/medicine/getmedicin
|
||||
{
|
||||
if (APIPharmacist.Pharmacist == null)
|
||||
{
|
||||
throw new Exception("Âû êàê ñþäà ïîïàëè? Ñþäà âõîä òîëüêî àâòîðèçîâàííûì");
|
||||
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
|
||||
}
|
||||
var result = APIPharmacist.GetRequest<AnimalViewModel>($"api/animal/getanimal?animalid={animalId}");
|
||||
return result;
|
||||
}
|
||||
|
||||
//public IActionResult CreateService()
|
||||
//{
|
||||
// if (APIPharmacist.Pharmacist == null)
|
||||
// {
|
||||
// return Redirect("~/Home/Enter");
|
||||
// }
|
||||
// ViewBag.Medicines = APIPharmacist.GetRequest<List<MedicineViewModel>>($"api/animal/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);
|
||||
// }
|
||||
|
||||
// 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();
|
||||
//}
|
||||
|
||||
//[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");
|
||||
//}
|
||||
|
||||
//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();
|
||||
//}
|
||||
|
||||
//[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");
|
||||
//}
|
||||
|
||||
//[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
|
||||
//public IActionResult Error()
|
||||
//{
|
||||
// return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
|
||||
//}
|
||||
|
||||
//[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;
|
||||
//}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -16,7 +16,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\VetClinicContracts\VetClinicContracts.csproj" />
|
||||
<ProjectReference Include="..\VetClinicDataBaseImplement\VetClinicDataBaseImplement.csproj" />
|
||||
<ProjectReference Include="..\VetClinicRestApi\VetClinicRestApi.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
@ -17,6 +17,7 @@
|
||||
<a asp-action="CreateMedicine">Создать медикамент</a>
|
||||
<a asp-action="UpdateMedicine">Обновить медикамент</a>
|
||||
<a asp-action="DeleteMedicine">Удалить медикамент</a>
|
||||
<a asp-action="MedicineAnimals">Связать медикаменты и животных</a>
|
||||
</p>
|
||||
<table class="table">
|
||||
<thead>
|
||||
|
65
VetClinic/PharmacistApp/Views/Home/MedicineAnimals.cshtml
Normal file
65
VetClinic/PharmacistApp/Views/Home/MedicineAnimals.cshtml
Normal file
@ -0,0 +1,65 @@
|
||||
@using VetClinicContracts.ViewModels;
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "MedicineAnimals";
|
||||
}
|
||||
|
||||
<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="medicine" name="medicine" class="form-control" asp-items="@(new SelectList(@ViewBag.Medicines, "Id", "MedicineName"))"></select>
|
||||
</div>
|
||||
</div>
|
||||
<input style = "visibility: hidden" type="text" name="name" id="name" class="form-control" />
|
||||
<input style = "visibility: hidden" type="text" id="price" name="price" class="form-control" />
|
||||
<div class="row">
|
||||
<div class="col-4">Животные:</div>
|
||||
<div class="col-8">
|
||||
<select name="animals" class="form-control" multiple size="5" id="animals">
|
||||
@foreach (var animal in ViewBag.Animals)
|
||||
{
|
||||
<option value="@animal.Id" id="@animal.AnimalName">@animal.AnimalName</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 medicine = $('#medicine').val();
|
||||
$("#animals option:selected").removeAttr("selected");
|
||||
if (medicine) {
|
||||
$.ajax({
|
||||
method: "GET",
|
||||
url: "/Home/GetMedicine",
|
||||
data: { medicineId: medicine },
|
||||
success: function (result) {
|
||||
console.log(result.item2);
|
||||
$('#name').val(result.item1.medicineName);
|
||||
$('#price').val(result.item1.price);
|
||||
$.map(result.item2, function (n) {
|
||||
console.log("#" + n);
|
||||
$("#" + n).attr("selected", "selected")
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
};
|
||||
}
|
||||
check();
|
||||
$('#medicine').on('change', function () {
|
||||
check();
|
||||
});
|
||||
</script>
|
||||
}
|
@ -13,9 +13,6 @@
|
||||
<div class="col-8">
|
||||
<select id="medicine" name="medicine" class="form-control" asp-items="@(new SelectList(@ViewBag.Medicines, "Id", "MedicineName"))"></select>
|
||||
</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>
|
||||
@ -23,20 +20,8 @@
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Цена:</div>
|
||||
<div class="col-8"><input type="number" id="price" name="price" class="form-control" /></div>
|
||||
<div class="col-8"><input type="text" id="price" name="price" class="form-control" /></div>
|
||||
</div>
|
||||
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
Животное
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="table-elements">
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="row">
|
||||
<div class="col-8"></div>
|
||||
<div class="col-4"><input type="submit" value="Сохранить" class="btn btn-primary" /></div>
|
||||
@ -48,16 +33,18 @@
|
||||
<script>
|
||||
function check() {
|
||||
var medicine = $('#medicine').val();
|
||||
$("#animals option:selected").removeAttr("selected");
|
||||
if (medicine) {
|
||||
$.ajax({
|
||||
method: "GET",
|
||||
url: "/Home/GetMedicine",
|
||||
data: { medicineId: medicine },
|
||||
success: function (result) {
|
||||
console.log(result.item2);
|
||||
$('#name').val(result.item1.medicineName);
|
||||
$('#price').val(result.item1.price);
|
||||
$('#table-elements').html(result.item2);
|
||||
}
|
||||
|
||||
});
|
||||
};
|
||||
}
|
||||
|
@ -4,6 +4,8 @@ using System.Diagnostics;
|
||||
using VetClinicContracts.BindingModels;
|
||||
using VetClinicContracts.ViewModels;
|
||||
using VetClinicDataModels.Models;
|
||||
using System.Text;
|
||||
using VetClinicContracts.SearchModels;
|
||||
|
||||
|
||||
namespace VetClinicAdminApp.Controllers
|
||||
@ -24,7 +26,7 @@ namespace VetClinicAdminApp.Controllers
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
return
|
||||
View(APIAdmin.GetRequest<List<VisitViewModel>>($"api/visit/getvisits?vistId={APIAdmin.Admin.Id}"));
|
||||
View(APIAdmin.GetRequest<List<VisitViewModel>>($"api/visit/getvisits?adminId={APIAdmin.Admin.Id}"));
|
||||
|
||||
}
|
||||
public IActionResult IndexAnimals()
|
||||
@ -34,7 +36,7 @@ View(APIAdmin.GetRequest<List<VisitViewModel>>($"api/visit/getvisits?vistId={API
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
return
|
||||
View(APIAdmin.GetRequest<List<AnimalViewModel>>($"api/animal/getanimallist?animalId={APIAdmin.Admin.Id}"));
|
||||
View(APIAdmin.GetRequest<List<AnimalViewModel>>($"api/animal/getanimallist?adminId={APIAdmin.Admin.Id}"));
|
||||
|
||||
}
|
||||
public IActionResult IndexVaccinations()
|
||||
@ -63,12 +65,12 @@ View(APIAdmin.GetRequest<List<VaccinationViewModel>>($"api/vaccination/getvaccin
|
||||
{
|
||||
if (APIAdmin.Admin == null)
|
||||
{
|
||||
throw new Exception("Âû êàê ñóäà ïîïàëè? Ñóäà âõîä òîëüêî àâòîðèçîâàííûì");
|
||||
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
|
||||
}
|
||||
if (string.IsNullOrEmpty(login) ||
|
||||
string.IsNullOrEmpty(password) || string.IsNullOrEmpty(fio))
|
||||
{
|
||||
throw new Exception("Ââåäèòå email, ïàðîëü è ÔÈÎ");
|
||||
throw new Exception("Введите email, пароль и ФИО");
|
||||
}
|
||||
APIAdmin.PostRequest("api/admin/updatedata", new
|
||||
AdminBindingModel
|
||||
@ -95,13 +97,13 @@ View(APIAdmin.GetRequest<List<VaccinationViewModel>>($"api/vaccination/getvaccin
|
||||
if (string.IsNullOrEmpty(login) ||
|
||||
string.IsNullOrEmpty(password))
|
||||
{
|
||||
throw new Exception("Ââåäèòå email è ïàðîëü");
|
||||
throw new Exception("Введите email и пароль");
|
||||
}
|
||||
APIAdmin.Admin =
|
||||
APIAdmin.GetRequest<AdminViewModel>($"api/admin/login?login={login}&password={password}");
|
||||
if (APIAdmin.Admin == null)
|
||||
{
|
||||
throw new Exception("Íåâåðíûé ëîãèí/ïàðîëü");
|
||||
throw new Exception("Неверный логин/пароль");
|
||||
}
|
||||
Response.Redirect("Index");
|
||||
}
|
||||
@ -116,7 +118,7 @@ View(APIAdmin.GetRequest<List<VaccinationViewModel>>($"api/vaccination/getvaccin
|
||||
if (string.IsNullOrEmpty(login) ||
|
||||
string.IsNullOrEmpty(password) || string.IsNullOrEmpty(fio))
|
||||
{
|
||||
throw new Exception("Ââåäèòå ëîãèí, ïàðîëü è ÔÈÎ");
|
||||
throw new Exception("Введите логин, пароль и ФИО");
|
||||
}
|
||||
APIAdmin.PostRequest("api/admin/register", new
|
||||
AdminBindingModel
|
||||
@ -156,11 +158,11 @@ View(APIAdmin.GetRequest<List<VaccinationViewModel>>($"api/vaccination/getvaccin
|
||||
{
|
||||
if (APIAdmin.Admin == null)
|
||||
{
|
||||
throw new Exception("Âû êàê ñþäà ïîïàëè? Ñþäà âõîä òîëüêî àâòîðèçîâàííûì");
|
||||
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
|
||||
}
|
||||
if (string.IsNullOrEmpty(name))
|
||||
{
|
||||
throw new Exception("Îøèáêà â ââåäåííûõ äàííûõ");
|
||||
throw new Exception("Ошибка в введенных данных");
|
||||
}
|
||||
APIAdmin.PostRequest("api/visit/createvisit", new VisitBindingModel
|
||||
{
|
||||
@ -175,11 +177,11 @@ View(APIAdmin.GetRequest<List<VaccinationViewModel>>($"api/vaccination/getvaccin
|
||||
{
|
||||
if (APIAdmin.Admin == null)
|
||||
{
|
||||
throw new Exception("Âû êàê ñþäà ïîïàëè? Ñþäà âõîä òîëüêî àâòîðèçîâàííûì");
|
||||
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
|
||||
}
|
||||
if (string.IsNullOrEmpty(animalname))
|
||||
{
|
||||
throw new Exception("Îøèáêà â ââåäåííûõ äàííûõ");
|
||||
throw new Exception("Ошибка в введенных данных");
|
||||
}
|
||||
APIAdmin.PostRequest("api/animal/createanimal", new AnimalBindingModel
|
||||
{
|
||||
@ -194,11 +196,11 @@ View(APIAdmin.GetRequest<List<VaccinationViewModel>>($"api/vaccination/getvaccin
|
||||
{
|
||||
if (APIAdmin.Admin == null)
|
||||
{
|
||||
throw new Exception("Âû êàê ñþäà ïîïàëè? Ñþäà âõîä òîëüêî àâòîðèçîâàííûì");
|
||||
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
|
||||
}
|
||||
if (string.IsNullOrEmpty(name))
|
||||
{
|
||||
throw new Exception("Îøèáêà â ââåäåííûõ äàííûõ");
|
||||
throw new Exception("Ошибка в введенных данных");
|
||||
}
|
||||
if (cost <= 0)
|
||||
{
|
||||
@ -225,11 +227,11 @@ View(APIAdmin.GetRequest<List<VaccinationViewModel>>($"api/vaccination/getvaccin
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void DeleteVisit(int visit)
|
||||
public void Delete(int visit)
|
||||
{
|
||||
if (APIAdmin.Admin == null)
|
||||
{
|
||||
throw new Exception("Âû êàê ñþäà ïîïàëè? Ñþäà âõîä òîëüêî àâòîðèçîâàííûì");
|
||||
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
|
||||
}
|
||||
APIAdmin.PostRequest("api/visit/deletevisit", new VisitBindingModel
|
||||
{
|
||||
@ -290,7 +292,7 @@ View(APIAdmin.GetRequest<List<VaccinationViewModel>>($"api/vaccination/getvaccin
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
ViewBag.Medicines = APIAdmin.GetRequest<List<MedicineViewModel>>("api/visit/getvisits");
|
||||
ViewBag.Visits = APIAdmin.GetRequest<List<VisitViewModel>>("api/visit/getvisits");
|
||||
return View();
|
||||
}
|
||||
|
||||
@ -299,11 +301,11 @@ View(APIAdmin.GetRequest<List<VaccinationViewModel>>($"api/vaccination/getvaccin
|
||||
{
|
||||
if (APIAdmin.Admin == null)
|
||||
{
|
||||
throw new Exception("Âû êàê ñþäà ïîïàëè? Ñþäà âõîä òîëüêî àâòîðèçîâàííûì");
|
||||
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
|
||||
}
|
||||
if (string.IsNullOrEmpty(name))
|
||||
{
|
||||
throw new Exception("Îøèáêà â ââåäåííûõ äàííûõ");
|
||||
throw new Exception("Ошибка в введенных данных");
|
||||
}
|
||||
APIAdmin.PostRequest("api/visit/updatevisit", new VisitBindingModel
|
||||
{
|
||||
@ -330,6 +332,7 @@ View(APIAdmin.GetRequest<List<VaccinationViewModel>>($"api/vaccination/getvaccin
|
||||
{
|
||||
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(name))
|
||||
{
|
||||
throw new Exception("Ошибка в введенных данных");
|
||||
@ -343,6 +346,82 @@ View(APIAdmin.GetRequest<List<VaccinationViewModel>>($"api/vaccination/getvaccin
|
||||
});
|
||||
Response.Redirect("IndexAnimals");
|
||||
}
|
||||
public IActionResult VisitAnimals()
|
||||
{
|
||||
if (APIAdmin.Admin == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
ViewBag.Animals = APIAdmin.GetRequest<List<AnimalViewModel>>($"api/animal/getanimallist?adminid={APIAdmin.Admin.Id}");
|
||||
ViewBag.Visits = APIAdmin.GetRequest<List<VisitViewModel>>($"api/visit/getvisits");
|
||||
return View();
|
||||
}
|
||||
[HttpPost]
|
||||
public void VisitAnimals(int animal, string name, string family,
|
||||
List<int> visits)
|
||||
{
|
||||
if (APIAdmin.Admin == null)
|
||||
{
|
||||
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(name) || string.IsNullOrEmpty(family))
|
||||
{
|
||||
throw new Exception("Ошибка в введенных данных");
|
||||
}
|
||||
Dictionary<int, IVisitModel> v = new Dictionary<int, IVisitModel>();
|
||||
foreach (int visit in visits)
|
||||
{
|
||||
v.Add(visit, new VisitSearchModel { Id = visit } as IVisitModel);
|
||||
}
|
||||
APIAdmin.PostRequest("api/animal/updateanimal?isconnection=true", new AnimalBindingModel
|
||||
{
|
||||
Id = animal,
|
||||
AnimalName = name,
|
||||
Family = family,
|
||||
AdminId = APIAdmin.Admin.Id,
|
||||
VisitAnimals = v
|
||||
});
|
||||
Response.Redirect("IndexAnimals");
|
||||
}
|
||||
public IActionResult ServiceVisits()
|
||||
{
|
||||
if (APIAdmin.Admin == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
ViewBag.Visits = APIAdmin.GetRequest<List<VisitViewModel>>($"api/visit/getvisits?adminid={APIAdmin.Admin.Id}");
|
||||
ViewBag.Services = APIAdmin.GetRequest<List<ServiceViewModel>>($"api/service/getservices");
|
||||
return View();
|
||||
}
|
||||
[HttpPost]
|
||||
public void ServiceVisits(int visit, string name, DateTime date,
|
||||
List<int> services)
|
||||
{
|
||||
if (APIAdmin.Admin == null)
|
||||
{
|
||||
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(name) || date == new DateTime())
|
||||
{
|
||||
throw new Exception("Ошибка в введенных данных");
|
||||
}
|
||||
Dictionary<int, IServiceModel> s = new Dictionary<int, IServiceModel>();
|
||||
foreach (int service in services)
|
||||
{
|
||||
s.Add(service, new ServiceSearchModel { Id = service } as IServiceModel);
|
||||
}
|
||||
APIAdmin.PostRequest("api/visit/updatevisit?isconnection=true", new VisitBindingModel
|
||||
{
|
||||
Id = visit,
|
||||
NameVisit = name,
|
||||
DateVisit = date,
|
||||
AdminId = APIAdmin.Admin.Id,
|
||||
ServiceVisits = s
|
||||
});
|
||||
Response.Redirect("Index");
|
||||
}
|
||||
public IActionResult UpdateVaccination()
|
||||
{
|
||||
if (APIAdmin.Admin == null)
|
||||
@ -383,27 +462,49 @@ View(APIAdmin.GetRequest<List<VaccinationViewModel>>($"api/vaccination/getvaccin
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public Tuple<VisitViewModel, string>? GetVisit(int visitId)
|
||||
public Tuple<VisitViewModel, List<string>>? GetVisit(int visitId)
|
||||
{
|
||||
if (APIAdmin.Admin == null)
|
||||
{
|
||||
throw new Exception("Âû êàê ñþäà ïîïàëè? Ñþäà âõîä òîëüêî àâòîðèçîâàííûì");
|
||||
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
|
||||
}
|
||||
var result = APIAdmin.GetRequest<Tuple<VisitViewModel, List<string>>>($"api/visit/getvisit?visitid={visitId}");
|
||||
if (result == null)
|
||||
{
|
||||
return default;
|
||||
}
|
||||
string table = "";
|
||||
result.Item1.VisitAnimals.Clear();
|
||||
for (int i = 0; i < result.Item2.Count; i++)
|
||||
|
||||
return result;
|
||||
}
|
||||
[HttpGet]
|
||||
public Tuple<AnimalViewModel, List<string>>? GetAnimal(int animalId)
|
||||
{
|
||||
if (APIAdmin.Admin == null)
|
||||
{
|
||||
var animal = result.Item2[i];
|
||||
table += "<tr>";
|
||||
table += $"<td>{animal}</td>";
|
||||
table += "</tr>";
|
||||
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
|
||||
}
|
||||
return Tuple.Create(result.Item1, table);
|
||||
var result = APIAdmin.GetRequest<Tuple<AnimalViewModel, List<string>>>($"api/animal/getanimal?animalid={animalId}");
|
||||
if (result == null)
|
||||
{
|
||||
return default;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
[HttpGet]
|
||||
public Tuple<ServiceViewModel, List<string>>? GetService(int serviceId)
|
||||
{
|
||||
if (APIAdmin.Admin == null)
|
||||
{
|
||||
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
|
||||
}
|
||||
var result = APIAdmin.GetRequest<Tuple<ServiceViewModel, List<string>>>($"api/service/getservice?serviceid={serviceId}");
|
||||
if (result == null)
|
||||
{
|
||||
return default;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10,13 +10,13 @@
|
||||
<div class="row">
|
||||
<div class="col-4">Название:</div>
|
||||
<div class="col-8">
|
||||
<input id="title" type="text" name="title" />
|
||||
<input type="text" name="name" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Дата:</div>
|
||||
<div class="col-8">
|
||||
<input type="date" id="date" name="date"/>
|
||||
<input type="datetime" id="datetime" name="date" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
|
18
VetClinic/VetClinicAdminApi/Views/Home/Delete.cshtml
Normal file
18
VetClinic/VetClinicAdminApi/Views/Home/Delete.cshtml
Normal file
@ -0,0 +1,18 @@
|
||||
@{
|
||||
ViewData["Title"] = "Delete";
|
||||
}
|
||||
<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="visit" name="visit" class="form-control" asp-items="@(new SelectList(@ViewBag.Visits, "Id", "NameVisit"))"></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>
|
@ -17,7 +17,11 @@
|
||||
<h3 class="display-4">Авторизируйтесь</h3>
|
||||
return;
|
||||
}
|
||||
|
||||
<p>
|
||||
<a asp-action="Update">Редактировать визит</a>
|
||||
<a asp-action="Delete">Удалить визит</a>
|
||||
<a asp-action="ServiceVisits">Связать визит и услуги</a>
|
||||
</p>
|
||||
<p>
|
||||
<a asp-action="Create">Создать визит</a>
|
||||
</p>
|
||||
|
@ -19,6 +19,7 @@
|
||||
}
|
||||
<p>
|
||||
<a asp-action="UpdateAnimal">Редактировать животное</a>
|
||||
<a asp-action="VisitAnimals">Связать животных и визиты </a>
|
||||
<a asp-action="DeleteAnimal">Удалить животное</a>
|
||||
</p>
|
||||
<p>
|
||||
|
65
VetClinic/VetClinicAdminApi/Views/Home/ServiceVisits.cshtml
Normal file
65
VetClinic/VetClinicAdminApi/Views/Home/ServiceVisits.cshtml
Normal file
@ -0,0 +1,65 @@
|
||||
@using VetClinicContracts.ViewModels;
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "ServiceVisits";
|
||||
}
|
||||
|
||||
<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="visit" name="visit" class="form-control" asp-items="@(new SelectList(@ViewBag.Visits, "Id", "NameVisit"))"></select>
|
||||
</div>
|
||||
</div>
|
||||
<input style = "visibility: hidden" type="text" name="name" id="name" class="form-control" />
|
||||
<input style="visibility: hidden" type="datetime" id="datetime" name="date" class="form-control" />
|
||||
<div class="row">
|
||||
<div class="col-4">Услуги:</div>
|
||||
<div class="col-8">
|
||||
<select name="services" class="form-control" multiple size="5" id="services">
|
||||
@foreach (var service in ViewBag.Services)
|
||||
{
|
||||
<option value="@service.Id" id="@service.ServicesName">@service.ServicesName</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 animal = $('#visit').val();
|
||||
$("#services option:selected").removeAttr("selected");
|
||||
if (animal) {
|
||||
$.ajax({
|
||||
method: "GET",
|
||||
url: "/Home/GetVisit",
|
||||
data: { animalId: animal },
|
||||
success: function (result) {
|
||||
console.log(result.item2);
|
||||
$('#name').val(result.item1.visitName);
|
||||
$('#date').val(result.item1.date);
|
||||
$.map(result.item2, function (n) {
|
||||
console.log("#" + n);
|
||||
$("#" + n).attr("selected", "selected")
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
};
|
||||
}
|
||||
check();
|
||||
$('#visit').on('change', function () {
|
||||
check();
|
||||
});
|
||||
</script>
|
||||
}
|
58
VetClinic/VetClinicAdminApi/Views/Home/Update.cshtml
Normal file
58
VetClinic/VetClinicAdminApi/Views/Home/Update.cshtml
Normal file
@ -0,0 +1,58 @@
|
||||
@using VetClinicContracts.ViewModels;
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Update";
|
||||
}
|
||||
|
||||
<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="visit" name="visit" class="form-control" asp-items="@(new SelectList(@ViewBag.Visits, "Id", "NameVisit"))"></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="datetime" id="datetime" 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>
|
||||
</form>
|
||||
|
||||
@section Scripts
|
||||
{
|
||||
<script>
|
||||
function check() {
|
||||
var visit = $('#visit').val();
|
||||
if (visit) {
|
||||
$.ajax({
|
||||
method: "GET",
|
||||
url: "/Home/GetVisit",
|
||||
data: { visitId: visit },
|
||||
success: function (result) {
|
||||
$('#name').val(result.item1.vistName);
|
||||
$('#date').val(result.item1.date);
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
check();
|
||||
$('#visit').on('change', function () {
|
||||
check();
|
||||
});
|
||||
</script>
|
||||
}
|
65
VetClinic/VetClinicAdminApi/Views/Home/VisitAnimals.cshtml
Normal file
65
VetClinic/VetClinicAdminApi/Views/Home/VisitAnimals.cshtml
Normal file
@ -0,0 +1,65 @@
|
||||
@using VetClinicContracts.ViewModels;
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "VisitAnimals";
|
||||
}
|
||||
|
||||
<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>
|
||||
<input style = "visibility: hidden" type="text" name="name" id="name" class="form-control" />
|
||||
<input style = "visibility: hidden" type="text" id="family" name="family" class="form-control" />
|
||||
<div class="row">
|
||||
<div class="col-4">Визиты:</div>
|
||||
<div class="col-8">
|
||||
<select name="visits" class="form-control" multiple size="5" id="visits">
|
||||
@foreach (var visit in ViewBag.Visits)
|
||||
{
|
||||
<option value="@visit.Id" id="@visit.NameVisit">@visit.NameVisit</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 animal = $('#animal').val();
|
||||
$("#visits option:selected").removeAttr("selected");
|
||||
if (animal) {
|
||||
$.ajax({
|
||||
method: "GET",
|
||||
url: "/Home/GetAnimal",
|
||||
data: { animalId: animal },
|
||||
success: function (result) {
|
||||
console.log(result.item2);
|
||||
$('#name').val(result.item1.animalName);
|
||||
$('#family').val(result.item1.family);
|
||||
$.map(result.item2, function (n) {
|
||||
console.log("#" + n);
|
||||
$("#" + n).attr("selected", "selected")
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
};
|
||||
}
|
||||
check();
|
||||
$('#animal').on('change', function () {
|
||||
check();
|
||||
});
|
||||
</script>
|
||||
}
|
@ -103,7 +103,7 @@ namespace VetClinicBusinessLogic.BusinessLogics
|
||||
throw new ArgumentNullException("Отсутствие пароля в учётной записи", nameof(model.Password));
|
||||
}
|
||||
|
||||
_logger.LogInformation("WorkPiece. AdminFIO:{AdminFIO}. Email:{Email}. Password:{Password}. Id:{Id}",
|
||||
_logger.LogInformation("Admin. AdminFIO:{AdminFIO}. Email:{Email}. Password:{Password}. Id:{Id}",
|
||||
model.AdminFIO, model.Email, model.Password, model.Id);
|
||||
var element = _adminStorage.GetElement(new AdminSearchModel
|
||||
{
|
||||
|
@ -46,7 +46,7 @@ namespace VetClinicBusinessLogic.BusinessLogics
|
||||
return element;
|
||||
}
|
||||
|
||||
public bool CreateAnimal(AnimalBindingModel model)
|
||||
public bool Create(AnimalBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
|
||||
@ -58,7 +58,7 @@ namespace VetClinicBusinessLogic.BusinessLogics
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool UpdateAnimal(AnimalBindingModel model)
|
||||
public bool Update(AnimalBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (_animalStorage.Update(model) == null)
|
||||
@ -69,7 +69,7 @@ namespace VetClinicBusinessLogic.BusinessLogics
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool DeleteAnimal(AnimalBindingModel model)
|
||||
public bool Delete(AnimalBindingModel model)
|
||||
{
|
||||
CheckModel(model, false);
|
||||
_logger.LogInformation("Delete. Id:{Id}", model.Id);
|
||||
@ -90,7 +90,7 @@ namespace VetClinicBusinessLogic.BusinessLogics
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (model.AnimalName == "")
|
||||
if (string.IsNullOrEmpty(model.AnimalName))
|
||||
{
|
||||
throw new ArgumentNullException("Имя не должно быть пустым", nameof(model.AnimalName));
|
||||
}
|
||||
@ -98,12 +98,17 @@ namespace VetClinicBusinessLogic.BusinessLogics
|
||||
{
|
||||
throw new ArgumentNullException("Некорректный идентификатор у клиента", nameof(model.AdminId));
|
||||
}
|
||||
|
||||
|
||||
var element = _animalStorage.GetElement(new AnimalSearchModel
|
||||
{
|
||||
Id = model.Id
|
||||
AnimalName = model.AnimalName
|
||||
|
||||
});
|
||||
|
||||
if (element != null && element.Id != model.Id)
|
||||
{
|
||||
throw new InvalidOperationException("Животное с таким названием уже есть");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -103,6 +103,15 @@ namespace VetClinicBusinessLogic.BusinessLogics
|
||||
}
|
||||
|
||||
_logger.LogInformation("Guidance. Text:{Text}.", model.Text);
|
||||
var element = _guidanceStorage.GetElement(new GuidanceSearchModel
|
||||
{
|
||||
Text = model.Text,
|
||||
ServiceId = model.ServiceId
|
||||
});
|
||||
if (element != null && element.Id != model.Id)
|
||||
{
|
||||
throw new InvalidOperationException("Рекомаендация для этой услуги с таким текстом уже есть");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -116,7 +116,7 @@ namespace VetClinicBusinessLogic.BusinessLogics
|
||||
});
|
||||
if (element != null && element.Id != model.Id)
|
||||
{
|
||||
throw new InvalidOperationException("Клиент с таким логином уже есть");
|
||||
throw new InvalidOperationException("Клиент с таким email'ом уже есть");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml.Linq;
|
||||
using VetClinicContracts.BindingModels;
|
||||
using VetClinicContracts.BusinessLogicsContracts;
|
||||
using VetClinicContracts.SearchModels;
|
||||
@ -107,6 +108,16 @@ namespace VetClinicBusinessLogic.BusinessLogics
|
||||
}
|
||||
|
||||
_logger.LogInformation("Vaccination. NameVaccination:{NameVaccination}. CostVaccination:{CostVaccination}", model.NameVaccination, model.CostVaccination);
|
||||
var element = _vaccinationStorage.GetElement(new VaccinationSearchModel
|
||||
{
|
||||
NameVaccination = model.NameVaccination,
|
||||
DateStamp = model.DateStamp,
|
||||
AnimalId = model.AnimalId,
|
||||
});
|
||||
if (element != null && element.Id != model.Id)
|
||||
{
|
||||
throw new InvalidOperationException("Прививка для этого услуги с таким текстом уже есть");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -101,8 +101,12 @@ true)
|
||||
throw new ArgumentNullException("Нет названия визита",
|
||||
nameof(model.NameVisit));
|
||||
}
|
||||
|
||||
_logger.LogInformation("Medicine. Medicine:{NameVisit}. Id: { Id}", model.NameVisit, model.Id);
|
||||
if (model.DateVisit != null)
|
||||
{
|
||||
throw new ArgumentNullException("Нет времени визита",
|
||||
nameof(model.DateVisit));
|
||||
}
|
||||
_logger.LogInformation("Visit. Visit:{NameVisit}. DateVisit:{ DateVisit } Id: { Id}", model.NameVisit, model.DateVisit, model.Id);
|
||||
var element = _visitStorage.GetElement(new VisitSearchModel
|
||||
{
|
||||
NameVisit = model.NameVisit
|
||||
|
@ -1,6 +1,8 @@
|
||||
namespace VetClinicContracts.BindingModels
|
||||
using VetClinicDataModels.Models;
|
||||
|
||||
namespace VetClinicContracts.BindingModels
|
||||
{
|
||||
public class AdminBindingModel
|
||||
public class AdminBindingModel : IAdminModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string AdminFIO { get; set; } = string.Empty;
|
||||
|
@ -7,11 +7,12 @@ using VetClinicDataModels.Models;
|
||||
|
||||
namespace VetClinicContracts.BindingModels
|
||||
{
|
||||
public class AnimalBindingModel
|
||||
public class AnimalBindingModel : IAnimalModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public int AdminId { get; set; }
|
||||
|
||||
public Dictionary<int, IVisitModel> VisitAnimals { get; set; } = new();
|
||||
public string AnimalName { get; set; } = string.Empty;
|
||||
|
||||
public string? Family { get; set; } = string.Empty;
|
||||
|
@ -14,6 +14,6 @@ namespace VetClinicContracts.BindingModels
|
||||
public string ServiceName { get; set; } = string.Empty;
|
||||
public double Price { get; set; }
|
||||
public int PharmacistId { get; set; }
|
||||
public Dictionary<int, (IMedicineModel, int)> ServiceMedicines { get; set; } = new();
|
||||
public Dictionary<int, IMedicineModel> ServiceMedicines { get; set; } = new();
|
||||
}
|
||||
}
|
||||
|
@ -7,12 +7,10 @@ using VetClinicDataModels.Models;
|
||||
|
||||
namespace VetClinicContracts.BindingModels
|
||||
{
|
||||
public class VisitBindingModel
|
||||
public class VisitBindingModel : IVisitModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public int AdminId { get; set; }
|
||||
public Dictionary<int, IAnimalModel> VisitAnimals { get; set; } = new();
|
||||
|
||||
public Dictionary<int, IServiceModel> ServiceVisits { get; set; } = new ();
|
||||
public string NameVisit { get; set; } = string.Empty;
|
||||
public DateTime DateVisit { get; set; }
|
||||
|
@ -13,8 +13,8 @@ namespace VetClinicContracts.BusinessLogicsContracts
|
||||
{
|
||||
List<AnimalViewModel>? ReadList(AnimalSearchModel? model);
|
||||
AnimalViewModel? ReadElement(AnimalSearchModel model);
|
||||
bool CreateAnimal(AnimalBindingModel model);
|
||||
bool UpdateAnimal(AnimalBindingModel model);
|
||||
bool DeleteAnimal(AnimalBindingModel model);
|
||||
bool Create(AnimalBindingModel model);
|
||||
bool Update(AnimalBindingModel model);
|
||||
bool Delete(AnimalBindingModel model);
|
||||
}
|
||||
}
|
||||
|
@ -12,6 +12,7 @@ namespace VetClinicContracts.SearchModels
|
||||
public string? NameVaccination { get; set; }
|
||||
public double? CostVaccination { get; set; }
|
||||
|
||||
public DateTime? DateStamp { get; set; }
|
||||
public DateTime? DateFrom { get; set; }
|
||||
public DateTime? DateTo { get; set; }
|
||||
|
||||
|
@ -19,5 +19,7 @@ namespace VetClinicContracts.ViewModels
|
||||
[DisplayName("Семейство")]
|
||||
|
||||
public string? Family { get; set; } = string.Empty;
|
||||
|
||||
public Dictionary<int, IVisitModel> VisitAnimals { get; set; } = new();
|
||||
}
|
||||
}
|
||||
|
@ -15,8 +15,6 @@ namespace VetClinicContracts.ViewModels
|
||||
public string MedicineName { get; set; } = string.Empty;
|
||||
[DisplayName("Цена медикамента")]
|
||||
public double Price { get; set; }
|
||||
[DisplayName("Фармацевт")]
|
||||
public string PharmacistFIO { get; set; } = string.Empty;
|
||||
public int PharmacistId { get; set; }
|
||||
public Dictionary<int, IAnimalModel> MedicineAnimals { get; set; } = new();
|
||||
}
|
||||
|
@ -18,6 +18,6 @@ namespace VetClinicContracts.ViewModels
|
||||
[DisplayName("Фармацевт")]
|
||||
public string PharmacistFIO { get; set; } = string.Empty;
|
||||
public int PharmacistId { get; set; }
|
||||
public Dictionary<int, (IMedicineModel, int)> ServiceMedicines { get; set; } = new();
|
||||
public Dictionary<int, IMedicineModel> ServiceMedicines { get; set; } = new();
|
||||
}
|
||||
}
|
||||
|
@ -14,21 +14,14 @@ namespace VetClinicContracts.ViewModels
|
||||
public int Id { get; set; }
|
||||
|
||||
public int AdminId { get; set; }
|
||||
[DisplayName("Животное")]
|
||||
public string AnimalName { get; set; } = string.Empty;
|
||||
|
||||
|
||||
[DisplayName("Название визита")]
|
||||
public string NameVisit { get; set; } = string.Empty;
|
||||
|
||||
[DisplayName("Админ")]
|
||||
public string AdminFIO { get; set; } = string.Empty;
|
||||
|
||||
[DisplayName("Название услуг")]
|
||||
public string ServiceName { get; set; } = string.Empty;
|
||||
|
||||
[DisplayName("Дата визита")]
|
||||
public DateTime DateVisit { get; set; }
|
||||
public Dictionary<int, IAnimalModel> VisitAnimals { get; set; } = new();
|
||||
|
||||
|
||||
public Dictionary<int, IServiceModel> ServiceVisits { get; set; } = new();
|
||||
}
|
||||
|
@ -35,23 +35,17 @@ namespace VetClinicDataBaseImplement.Implements
|
||||
public AdminViewModel? GetElement(AdminSearchModel model)
|
||||
{
|
||||
using var context = new VetClinicDatabase();
|
||||
if (model.Id.HasValue)
|
||||
if (string.IsNullOrEmpty(model.AdminFIO) && string.IsNullOrEmpty(model.Email) &&
|
||||
!model.Id.HasValue)
|
||||
{
|
||||
return context.Admins
|
||||
.Include(x => x.Visits)
|
||||
.Include(x => x.Animals)
|
||||
.FirstOrDefault(x => model.Id.HasValue && x.Id == model.Id)
|
||||
?.GetViewModel;
|
||||
return null;
|
||||
}
|
||||
else if (!string.IsNullOrEmpty(model.Email) && !string.IsNullOrEmpty(model.Password))
|
||||
{
|
||||
return context.Admins
|
||||
.Include(x => x.Visits)
|
||||
.Include(x => x.Animals)
|
||||
.FirstOrDefault(x => (x.Email == model.Email && x.Password == model.Password))
|
||||
?.GetViewModel;
|
||||
}
|
||||
return new();
|
||||
|
||||
return context.Admins
|
||||
.FirstOrDefault(x => (string.IsNullOrEmpty(model.AdminFIO) || x.AdminFIO == model.AdminFIO) &&
|
||||
(!model.Id.HasValue || x.Id == model.Id) && (string.IsNullOrEmpty(model.Email) || x.Email == model.Email) &&
|
||||
(string.IsNullOrEmpty(model.Password) || x.Password == model.Password))
|
||||
?.GetViewModel;
|
||||
}
|
||||
|
||||
public List<AdminViewModel> GetFilteredList(AdminSearchModel model)
|
||||
|
@ -16,22 +16,21 @@ namespace VetClinicBaseImplement.Implements
|
||||
|
||||
return context.Animals
|
||||
.Include(x => x.Admin)
|
||||
.Include(x => x.Visits)
|
||||
.ThenInclude(x => x.Visit)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
public List<AnimalViewModel> GetFilteredList(AnimalSearchModel model)
|
||||
{
|
||||
|
||||
if (string.IsNullOrEmpty(model.AnimalName))
|
||||
{
|
||||
return new();
|
||||
}
|
||||
using var context = new VetClinicDatabase();
|
||||
return context.Animals
|
||||
.Include(x => x.Admin)
|
||||
.Where(x => x.AnimalName.Contains(model.AnimalName))
|
||||
.ToList()
|
||||
.Select(x => x.GetViewModel).ToList();
|
||||
return context.Animals.Include(x => x.Admin).Include(x => x.Visits)
|
||||
.ThenInclude(x => x.Visit)
|
||||
.Where(x => (string.IsNullOrEmpty(model.AnimalName) || x.AnimalName.Contains(model.AnimalName))
|
||||
&& (!model.AdminId.HasValue || x.AdminId == model.AdminId))
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
public AnimalViewModel? GetElement(AnimalSearchModel model)
|
||||
{
|
||||
@ -42,6 +41,8 @@ namespace VetClinicBaseImplement.Implements
|
||||
using var context = new VetClinicDatabase();
|
||||
return context.Animals
|
||||
.Include(x => x.Admin)
|
||||
.Include(x => x.Visits)
|
||||
.ThenInclude(x => x.Visit)
|
||||
.Include(x => x.Vaccinations)
|
||||
.FirstOrDefault(x => (!string.IsNullOrEmpty(model.AnimalName) && x.AnimalName == model.AnimalName) || (model.Id.HasValue && x.Id == model.Id))?.GetViewModel;
|
||||
}
|
||||
@ -54,6 +55,7 @@ namespace VetClinicBaseImplement.Implements
|
||||
return null;
|
||||
}
|
||||
context.Animals.Add(newAnimal);
|
||||
|
||||
context.SaveChanges();
|
||||
return newAnimal.GetViewModel;
|
||||
}
|
||||
@ -64,13 +66,21 @@ namespace VetClinicBaseImplement.Implements
|
||||
|
||||
try
|
||||
{
|
||||
var animal = context.Animals.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
var animal = context.Animals.Include(x => x.Admin)
|
||||
.Include(x => x.Visits)
|
||||
.ThenInclude(x => x.Visit).FirstOrDefault(rec =>
|
||||
rec.Id == model.Id);
|
||||
if (animal == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
animal.Update(model);
|
||||
context.SaveChanges();
|
||||
if (model.VisitAnimals != null)
|
||||
{
|
||||
animal.UpdateVisits(context, model);
|
||||
}
|
||||
|
||||
transaction.Commit();
|
||||
return animal.GetViewModel;
|
||||
}
|
||||
@ -85,6 +95,7 @@ namespace VetClinicBaseImplement.Implements
|
||||
using var context = new VetClinicDatabase();
|
||||
var element = context.Animals
|
||||
.Include(x => x.Vaccinations)
|
||||
.Include(x => x.Visits).ThenInclude(x => x.Visit)
|
||||
.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
|
||||
if (element != null)
|
||||
|
@ -19,7 +19,6 @@ namespace VetClinicDataBaseImplement.Implements
|
||||
using var context = new VetClinicDatabase();
|
||||
return context.Medicines.Include(x => x.Pharmacist).Include(x => x.Animals)
|
||||
.ThenInclude(x => x.Animal)
|
||||
.ToList()
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
@ -30,7 +29,6 @@ namespace VetClinicDataBaseImplement.Implements
|
||||
.ThenInclude(x => x.Animal)
|
||||
.Where(x => (string.IsNullOrEmpty(model.MedicineName) || x.MedicineName.Contains(model.MedicineName))
|
||||
&& (!model.PharmacistId.HasValue || x.PharmacistId == model.PharmacistId))
|
||||
.ToList()
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
@ -79,7 +77,8 @@ namespace VetClinicDataBaseImplement.Implements
|
||||
}
|
||||
medicine.Update(model);
|
||||
context.SaveChanges();
|
||||
medicine.UpdateAnimals(context, model);
|
||||
if(model.MedicineAnimals != null)
|
||||
medicine.UpdateAnimals(context, model);
|
||||
transaction.Commit();
|
||||
return medicine.GetViewModel;
|
||||
}
|
||||
|
@ -21,8 +21,7 @@ namespace VetClinicDataBaseImplement.Implements
|
||||
return context.Visits
|
||||
|
||||
.Include(x => x.Admin)
|
||||
.Include(x => x.Animals)
|
||||
.ThenInclude(x => x.Animal)
|
||||
|
||||
.Include(x => x.Services)
|
||||
.ThenInclude(x => x.Service)
|
||||
.Select(x => x.GetViewModel)
|
||||
@ -30,22 +29,13 @@ namespace VetClinicDataBaseImplement.Implements
|
||||
}
|
||||
public List<VisitViewModel> GetFilteredList(VisitSearchModel model)
|
||||
{
|
||||
|
||||
if (string.IsNullOrEmpty(model.NameVisit))
|
||||
{
|
||||
return new();
|
||||
}
|
||||
using var context = new VetClinicDatabase();
|
||||
return context.Visits
|
||||
.Include(x => x.Admin)
|
||||
.Include(x => x.Animals)
|
||||
.ThenInclude(x => x.Animal)
|
||||
.Where(x => x.NameVisit.Contains(model.NameVisit))
|
||||
.Include(x => x.Services)
|
||||
return context.Visits.Include(x => x.Admin).Include(x => x.Services)
|
||||
.ThenInclude(x => x.Service)
|
||||
.Where(x => x.NameVisit.Contains(model.NameVisit))
|
||||
.ToList()
|
||||
.Select(x => x.GetViewModel).ToList();
|
||||
.Where(x => (string.IsNullOrEmpty(model.NameVisit) || x.NameVisit.Contains(model.NameVisit))
|
||||
&& (!model.AdminId.HasValue || x.AdminId == model.AdminId))
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
public VisitViewModel? GetElement(VisitSearchModel model)
|
||||
{
|
||||
@ -56,11 +46,13 @@ namespace VetClinicDataBaseImplement.Implements
|
||||
using var context = new VetClinicDatabase();
|
||||
return context.Visits
|
||||
.Include(x => x.Admin)
|
||||
.Include(x => x.Animals)
|
||||
.ThenInclude(x => x.Animal)
|
||||
.Include(x => x.Services)
|
||||
.ThenInclude(x => x.Service)
|
||||
.FirstOrDefault(x => (!string.IsNullOrEmpty(model.NameVisit) && x.NameVisit == model.NameVisit) || (model.Id.HasValue && x.Id == model.Id))?.GetViewModel;
|
||||
.FirstOrDefault(x => (!string.IsNullOrEmpty(model.NameVisit) &&
|
||||
x.NameVisit == model.NameVisit) ||
|
||||
(model.Id.HasValue && x.Id ==
|
||||
model.Id))
|
||||
?.GetViewModel;
|
||||
}
|
||||
public VisitViewModel? Insert(VisitBindingModel model)
|
||||
{
|
||||
@ -88,7 +80,8 @@ namespace VetClinicDataBaseImplement.Implements
|
||||
}
|
||||
visit.Update(model);
|
||||
context.SaveChanges();
|
||||
visit.UpdateAnimals(context, model);
|
||||
if (model.ServiceVisits != null)
|
||||
visit.UpdateServices(context, model);
|
||||
transaction.Commit();
|
||||
return visit.GetViewModel;
|
||||
}
|
||||
@ -102,11 +95,10 @@ namespace VetClinicDataBaseImplement.Implements
|
||||
{
|
||||
using var context = new VetClinicDatabase();
|
||||
var element = context.Visits
|
||||
.Include(x => x.Animals).ThenInclude(x => x.Animal)
|
||||
.Include(x => x.Admin)
|
||||
.Include(x => x.Services).ThenInclude(x => x.Service)
|
||||
.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
|
||||
|
||||
|
||||
if (element != null)
|
||||
{
|
||||
|
||||
|
@ -1,387 +0,0 @@
|
||||
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),
|
||||
Count = 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");
|
||||
}
|
||||
}
|
||||
}
|
@ -12,7 +12,7 @@ using VetClinicDataBaseImplement;
|
||||
namespace VetClinicDataBaseImplement.Migrations
|
||||
{
|
||||
[DbContext(typeof(VetClinicDatabase))]
|
||||
[Migration("20240427074910_InitialCreate")]
|
||||
[Migration("20240428120220_InitialCreate")]
|
||||
partial class InitialCreate
|
||||
{
|
||||
/// <inheritdoc />
|
||||
@ -207,9 +207,6 @@ namespace VetClinicDataBaseImplement.Migrations
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("MedicineId")
|
||||
.HasColumnType("int");
|
||||
|
@ -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");
|
||||
}
|
||||
}
|
||||
}
|
@ -10,506 +10,503 @@ using VetClinicDataBaseImplement;
|
||||
|
||||
namespace VetClinicDataBaseImplement.Migrations
|
||||
{
|
||||
[DbContext(typeof(VetClinicDatabase))]
|
||||
partial class VetClinicDatabaseModelSnapshot : ModelSnapshot
|
||||
{
|
||||
protected override void BuildModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
[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);
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "8.0.4")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||
|
||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("VetClinicDataBaseImplement.Models.Admin", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
modelBuilder.Entity("VetClinicDataBaseImplement.Models.Admin", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("AdminFIO")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
b.Property<string>("AdminFIO")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Email")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
b.Property<string>("Email")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Password")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
b.Property<string>("Password")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Admins");
|
||||
});
|
||||
b.ToTable("Admins");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VetClinicDataBaseImplement.Models.Animal", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
modelBuilder.Entity("VetClinicDataBaseImplement.Models.Animal", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("AdminId")
|
||||
.HasColumnType("int");
|
||||
b.Property<int>("AdminId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("AnimalName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
b.Property<string>("AnimalName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Family")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
b.Property<string>("Family")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("AdminId");
|
||||
b.HasIndex("AdminId");
|
||||
|
||||
b.ToTable("Animals");
|
||||
});
|
||||
b.ToTable("Animals");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VetClinicDataBaseImplement.Models.Guidance", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
modelBuilder.Entity("VetClinicDataBaseImplement.Models.Guidance", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<DateTime>("Date")
|
||||
.HasColumnType("datetime2");
|
||||
b.Property<DateTime>("Date")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<int>("ServiceId")
|
||||
.HasColumnType("int");
|
||||
b.Property<int>("ServiceId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("Text")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
b.Property<string>("Text")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ServiceId");
|
||||
b.HasIndex("ServiceId");
|
||||
|
||||
b.ToTable("Guidances");
|
||||
});
|
||||
b.ToTable("Guidances");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VetClinicDataBaseImplement.Models.Medicine", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
modelBuilder.Entity("VetClinicDataBaseImplement.Models.Medicine", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("MedicineName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
b.Property<string>("MedicineName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int>("PharmacistId")
|
||||
.HasColumnType("int");
|
||||
b.Property<int>("PharmacistId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<double>("Price")
|
||||
.HasColumnType("float");
|
||||
b.Property<double>("Price")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.HasKey("Id");
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("PharmacistId");
|
||||
b.HasIndex("PharmacistId");
|
||||
|
||||
b.ToTable("Medicines");
|
||||
});
|
||||
b.ToTable("Medicines");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VetClinicDataBaseImplement.Models.MedicineAnimal", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
modelBuilder.Entity("VetClinicDataBaseImplement.Models.MedicineAnimal", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("AnimalId")
|
||||
.HasColumnType("int");
|
||||
b.Property<int>("AnimalId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("MedicineId")
|
||||
.HasColumnType("int");
|
||||
b.Property<int>("MedicineId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("AnimalId");
|
||||
b.HasIndex("AnimalId");
|
||||
|
||||
b.HasIndex("MedicineId");
|
||||
b.HasIndex("MedicineId");
|
||||
|
||||
b.ToTable("MedicineAnimals");
|
||||
});
|
||||
b.ToTable("MedicineAnimals");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VetClinicDataBaseImplement.Models.Pharmacist", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
modelBuilder.Entity("VetClinicDataBaseImplement.Models.Pharmacist", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Email")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
b.Property<string>("Email")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Password")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
b.Property<string>("Password")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("PharmacistFIO")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
b.Property<string>("PharmacistFIO")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Pharmacists");
|
||||
});
|
||||
b.ToTable("Pharmacists");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VetClinicDataBaseImplement.Models.Service", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
modelBuilder.Entity("VetClinicDataBaseImplement.Models.Service", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("PharmacistId")
|
||||
.HasColumnType("int");
|
||||
b.Property<int>("PharmacistId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<double>("Price")
|
||||
.HasColumnType("float");
|
||||
b.Property<double>("Price")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.Property<string>("ServiceName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
b.Property<string>("ServiceName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("PharmacistId");
|
||||
b.HasIndex("PharmacistId");
|
||||
|
||||
b.ToTable("Services");
|
||||
});
|
||||
b.ToTable("Services");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VetClinicDataBaseImplement.Models.ServiceMedicine", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
modelBuilder.Entity("VetClinicDataBaseImplement.Models.ServiceMedicine", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("int");
|
||||
b.Property<int>("MedicineId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("MedicineId")
|
||||
.HasColumnType("int");
|
||||
b.Property<int>("ServiceId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("ServiceId")
|
||||
.HasColumnType("int");
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasKey("Id");
|
||||
b.HasIndex("MedicineId");
|
||||
|
||||
b.HasIndex("MedicineId");
|
||||
b.HasIndex("ServiceId");
|
||||
|
||||
b.HasIndex("ServiceId");
|
||||
b.ToTable("ServiceMedicines");
|
||||
});
|
||||
|
||||
b.ToTable("ServiceMedicines");
|
||||
});
|
||||
modelBuilder.Entity("VetClinicDataBaseImplement.Models.Vaccination", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
modelBuilder.Entity("VetClinicDataBaseImplement.Models.Vaccination", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
b.Property<int>("AnimalId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("AnimalId")
|
||||
.HasColumnType("int");
|
||||
b.Property<double>("CostVaccination")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.Property<double>("CostVaccination")
|
||||
.HasColumnType("float");
|
||||
b.Property<DateTime?>("DateStamp")
|
||||
.IsRequired()
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<DateTime?>("DateStamp")
|
||||
.IsRequired()
|
||||
.HasColumnType("datetime2");
|
||||
b.Property<string>("NameVaccination")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("NameVaccination")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasKey("Id");
|
||||
b.HasIndex("AnimalId");
|
||||
|
||||
b.HasIndex("AnimalId");
|
||||
b.ToTable("Vaccinations");
|
||||
});
|
||||
|
||||
b.ToTable("Vaccinations");
|
||||
});
|
||||
modelBuilder.Entity("VetClinicDataBaseImplement.Models.Visit", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
modelBuilder.Entity("VetClinicDataBaseImplement.Models.Visit", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
b.Property<int>("AdminId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("AdminId")
|
||||
.HasColumnType("int");
|
||||
b.Property<DateTime>("DateVisit")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<DateTime>("DateVisit")
|
||||
.HasColumnType("datetime2");
|
||||
b.Property<string>("NameVisit")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("NameVisit")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasKey("Id");
|
||||
b.HasIndex("AdminId");
|
||||
|
||||
b.HasIndex("AdminId");
|
||||
b.ToTable("Visits");
|
||||
});
|
||||
|
||||
b.ToTable("Visits");
|
||||
});
|
||||
modelBuilder.Entity("VetClinicDataBaseImplement.Models.VisitAnimal", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
modelBuilder.Entity("VetClinicDataBaseImplement.Models.VisitAnimal", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
b.Property<int>("AnimalId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("AnimalId")
|
||||
.HasColumnType("int");
|
||||
b.Property<int>("VisitId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("VisitId")
|
||||
.HasColumnType("int");
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasKey("Id");
|
||||
b.HasIndex("AnimalId");
|
||||
|
||||
b.HasIndex("AnimalId");
|
||||
b.HasIndex("VisitId");
|
||||
|
||||
b.HasIndex("VisitId");
|
||||
b.ToTable("VisitAnimals");
|
||||
});
|
||||
|
||||
b.ToTable("VisitAnimals");
|
||||
});
|
||||
modelBuilder.Entity("VetClinicDataBaseImplement.Models.VisitService", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
modelBuilder.Entity("VetClinicDataBaseImplement.Models.VisitService", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
b.Property<int>("ServiceId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("ServiceId")
|
||||
.HasColumnType("int");
|
||||
b.Property<int>("VisitId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("VisitId")
|
||||
.HasColumnType("int");
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasKey("Id");
|
||||
b.HasIndex("ServiceId");
|
||||
|
||||
b.HasIndex("ServiceId");
|
||||
b.HasIndex("VisitId");
|
||||
|
||||
b.HasIndex("VisitId");
|
||||
b.ToTable("ServiceVisits");
|
||||
});
|
||||
|
||||
b.ToTable("ServiceVisits");
|
||||
});
|
||||
modelBuilder.Entity("VetClinicDataBaseImplement.Models.Animal", b =>
|
||||
{
|
||||
b.HasOne("VetClinicDataBaseImplement.Models.Admin", "Admin")
|
||||
.WithMany("Animals")
|
||||
.HasForeignKey("AdminId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
modelBuilder.Entity("VetClinicDataBaseImplement.Models.Animal", b =>
|
||||
{
|
||||
b.HasOne("VetClinicDataBaseImplement.Models.Admin", "Admin")
|
||||
.WithMany("Animals")
|
||||
.HasForeignKey("AdminId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
b.Navigation("Admin");
|
||||
});
|
||||
|
||||
b.Navigation("Admin");
|
||||
});
|
||||
modelBuilder.Entity("VetClinicDataBaseImplement.Models.Guidance", b =>
|
||||
{
|
||||
b.HasOne("VetClinicDataBaseImplement.Models.Service", "Service")
|
||||
.WithMany("Guidances")
|
||||
.HasForeignKey("ServiceId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
modelBuilder.Entity("VetClinicDataBaseImplement.Models.Guidance", b =>
|
||||
{
|
||||
b.HasOne("VetClinicDataBaseImplement.Models.Service", "Service")
|
||||
.WithMany("Guidances")
|
||||
.HasForeignKey("ServiceId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
b.Navigation("Service");
|
||||
});
|
||||
|
||||
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");
|
||||
|
||||
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("Services");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VetClinicDataBaseImplement.Models.Service", b =>
|
||||
{
|
||||
b.Navigation("Guidances");
|
||||
b.Navigation("Medicines");
|
||||
|
||||
b.Navigation("Medicines");
|
||||
b.Navigation("Visits");
|
||||
});
|
||||
|
||||
b.Navigation("Visits");
|
||||
});
|
||||
modelBuilder.Entity("VetClinicDataBaseImplement.Models.Visit", b =>
|
||||
{
|
||||
b.Navigation("Animals");
|
||||
|
||||
modelBuilder.Entity("VetClinicDataBaseImplement.Models.Visit", b =>
|
||||
{
|
||||
b.Navigation("Animals");
|
||||
|
||||
b.Navigation("Services");
|
||||
});
|
||||
b.Navigation("Services");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -37,7 +37,22 @@ namespace VetClinicDataBaseImplement.Models
|
||||
|
||||
[ForeignKey("AnimalId")]
|
||||
public virtual List<MedicineAnimal> Medicines { get; set; } = new();
|
||||
|
||||
|
||||
public Dictionary<int, IVisitModel>? _visitAnimals = null;
|
||||
|
||||
[NotMapped]
|
||||
public Dictionary<int, IVisitModel> VisitAnimals
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_visitAnimals == null)
|
||||
{
|
||||
_visitAnimals = Visits.ToDictionary(recPC => recPC.VisitId, recPC =>
|
||||
recPC.Visit as IVisitModel);
|
||||
}
|
||||
return _visitAnimals;
|
||||
}
|
||||
}
|
||||
public static Animal? Create(VetClinicDatabase context, AnimalBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
@ -50,7 +65,10 @@ namespace VetClinicDataBaseImplement.Models
|
||||
AdminId = model.AdminId,
|
||||
AnimalName = model.AnimalName,
|
||||
Family = model.Family,
|
||||
|
||||
Visits = model.VisitAnimals.Select(x => new VisitAnimal
|
||||
{
|
||||
Visit = context.Visits.First(y => y.Id == x.Key)
|
||||
}).ToList()
|
||||
};
|
||||
}
|
||||
public void Update(AnimalBindingModel? model)
|
||||
@ -65,11 +83,33 @@ namespace VetClinicDataBaseImplement.Models
|
||||
public AnimalViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
VisitAnimals = VisitAnimals,
|
||||
AdminId = AdminId,
|
||||
AnimalName = AnimalName,
|
||||
Family = Family
|
||||
|
||||
};
|
||||
|
||||
public void UpdateVisits(VetClinicDatabase context, AnimalBindingModel model)
|
||||
{
|
||||
var visitAnimals = context.VisitAnimals.Where(rec => rec.AnimalId == model.Id).ToList();
|
||||
if (visitAnimals != null)
|
||||
{ // удалили те, которых нет в модели
|
||||
context.VisitAnimals.RemoveRange(visitAnimals.Where(rec => !model.VisitAnimals.ContainsKey(rec.VisitId)));
|
||||
context.SaveChanges();
|
||||
|
||||
}
|
||||
var animal = context.Animals.First(x => x.Id == Id);
|
||||
foreach (var pc in model.VisitAnimals)
|
||||
{
|
||||
context.VisitAnimals.Add(new VisitAnimal
|
||||
{
|
||||
Animal = animal,
|
||||
Visit = context.Visits.First(x => x.Id == pc.Key),
|
||||
|
||||
});
|
||||
context.SaveChanges();
|
||||
}
|
||||
_visitAnimals = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -54,6 +54,7 @@ namespace VetClinicDataBaseImplement.Models
|
||||
{
|
||||
Animal = context.Animals.First(y => y.Id == x.Key),
|
||||
}).ToList(),
|
||||
PharmacistId = model.PharmacistId,
|
||||
Pharmacist = context.Pharmacists.First(x => x.Id == model.PharmacistId)
|
||||
};
|
||||
}
|
||||
@ -68,7 +69,6 @@ namespace VetClinicDataBaseImplement.Models
|
||||
MedicineName = MedicineName,
|
||||
Price = Price,
|
||||
MedicineAnimals = MedicineAnimals,
|
||||
PharmacistFIO = Pharmacist.PharmacistFIO
|
||||
};
|
||||
public void UpdateAnimals(VetClinicDatabase context,
|
||||
MedicineBindingModel model)
|
||||
@ -81,7 +81,10 @@ namespace VetClinicDataBaseImplement.Models
|
||||
{
|
||||
context.MedicineAnimals.RemoveRange(medicineAnimals.Where(rec
|
||||
=> !model.MedicineAnimals.ContainsKey(rec.AnimalId)));
|
||||
|
||||
foreach (var animal in medicineAnimals)
|
||||
{
|
||||
model.MedicineAnimals.Remove(animal.AnimalId);
|
||||
}
|
||||
context.SaveChanges();
|
||||
}
|
||||
var medicine = context.Medicines.First(x => x.Id == Id);
|
||||
|
@ -22,10 +22,10 @@ namespace VetClinicDataBaseImplement.Models
|
||||
[Required]
|
||||
public int PharmacistId { get; set; }
|
||||
public virtual Pharmacist Pharmacist { get; private set; }
|
||||
private Dictionary<int, (IMedicineModel, int)>? _serviceMedicines =
|
||||
private Dictionary<int, IMedicineModel>? _serviceMedicines =
|
||||
null;
|
||||
[NotMapped]
|
||||
public Dictionary<int, (IMedicineModel, int)> ServiceMedicines
|
||||
public Dictionary<int, IMedicineModel> ServiceMedicines
|
||||
{
|
||||
get
|
||||
{
|
||||
@ -33,7 +33,7 @@ namespace VetClinicDataBaseImplement.Models
|
||||
{
|
||||
_serviceMedicines = Medicines
|
||||
.ToDictionary(recPC => recPC.MedicineId, recPC =>
|
||||
(recPC.Medicine as IMedicineModel, recPC.Count));
|
||||
(recPC.Medicine as IMedicineModel));
|
||||
}
|
||||
return _serviceMedicines;
|
||||
}
|
||||
@ -56,7 +56,6 @@ namespace VetClinicDataBaseImplement.Models
|
||||
ServiceMedicine
|
||||
{
|
||||
Medicine = context.Medicines.First(y => y.Id == x.Key),
|
||||
Count = x.Value.Item2
|
||||
}).ToList()
|
||||
};
|
||||
}
|
||||
@ -85,8 +84,6 @@ namespace VetClinicDataBaseImplement.Models
|
||||
context.SaveChanges();
|
||||
foreach (var updateComponent in serviceMedicines)
|
||||
{
|
||||
updateComponent.Count =
|
||||
model.ServiceMedicines[updateComponent.MedicineId].Item2;
|
||||
model.ServiceMedicines.Remove(updateComponent.MedicineId);
|
||||
}
|
||||
context.SaveChanges();
|
||||
@ -98,7 +95,6 @@ namespace VetClinicDataBaseImplement.Models
|
||||
{
|
||||
Service = service,
|
||||
Medicine = context.Medicines.Include(x => x.Animals).ThenInclude(x => x.Animal).First(x => x.Id == pc.Key),
|
||||
Count = pc.Value.Item2
|
||||
});
|
||||
context.SaveChanges();
|
||||
}
|
||||
|
@ -15,8 +15,6 @@ namespace VetClinicDataBaseImplement.Models
|
||||
public int ServiceId { get; set; }
|
||||
[Required]
|
||||
public int MedicineId { get; set; }
|
||||
[Required]
|
||||
public int Count { get; set; }
|
||||
public virtual Service Service { get; set; } = new();
|
||||
public virtual Medicine Medicine { get; set; } = new();
|
||||
}
|
||||
|
@ -31,23 +31,11 @@ namespace VetClinicDataBaseImplement.Models
|
||||
[ForeignKey("VisitId")]
|
||||
public virtual List<VisitService> Services { get; set; } = new();
|
||||
public virtual Admin Admin { get; set; }
|
||||
public Dictionary<int, IAnimalModel>? _visitAnimals = null;
|
||||
|
||||
|
||||
public Dictionary<int, IServiceModel>? _serviceVisits = null;
|
||||
|
||||
[NotMapped]
|
||||
public Dictionary<int, IAnimalModel> VisitAnimals
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_visitAnimals == null)
|
||||
{
|
||||
_visitAnimals = Animals.ToDictionary(recPC => recPC.AnimalId, recPC =>
|
||||
recPC.Animal as IAnimalModel);
|
||||
}
|
||||
return _visitAnimals;
|
||||
}
|
||||
}
|
||||
|
||||
[NotMapped]
|
||||
public Dictionary<int, IServiceModel> ServiceVisits
|
||||
{
|
||||
@ -74,10 +62,6 @@ namespace VetClinicDataBaseImplement.Models
|
||||
|
||||
NameVisit = model.NameVisit,
|
||||
DateVisit = model.DateVisit,
|
||||
Animals = model.VisitAnimals.Select(x => new VisitAnimal
|
||||
{
|
||||
Animal = context.Animals.First(y => y.Id == x.Key)
|
||||
}).ToList(),
|
||||
Services = model.ServiceVisits.Select(x => new VisitService
|
||||
{
|
||||
Service = context.Services.First(y => y.Id == x.Key)
|
||||
@ -96,36 +80,15 @@ namespace VetClinicDataBaseImplement.Models
|
||||
public VisitViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
VisitAnimals = VisitAnimals,
|
||||
|
||||
AdminId = AdminId,
|
||||
NameVisit = NameVisit,
|
||||
DateVisit = DateVisit,
|
||||
ServiceVisits = ServiceVisits
|
||||
|
||||
};
|
||||
public void UpdateAnimals(VetClinicDatabase context, VisitBindingModel model)
|
||||
{
|
||||
var visitAnimals = context.VisitAnimals.Where(rec => rec.VisitId == model.Id).ToList();
|
||||
if (visitAnimals != null)
|
||||
{ // удалили те, которых нет в модели
|
||||
context.VisitAnimals.RemoveRange(visitAnimals.Where(rec => !model.VisitAnimals.ContainsKey(rec.AnimalId)));
|
||||
context.SaveChanges();
|
||||
|
||||
}
|
||||
var visit = context.Visits.First(x => x.Id == Id);
|
||||
foreach (var pc in model.VisitAnimals)
|
||||
{
|
||||
context.VisitAnimals.Add(new VisitAnimal
|
||||
{
|
||||
Visit = visit,
|
||||
Animal = context.Animals.First(x => x.Id == pc.Key),
|
||||
|
||||
});
|
||||
context.SaveChanges();
|
||||
}
|
||||
_visitAnimals = null;
|
||||
}
|
||||
public void UpdateService(VetClinicDatabase context, VisitBindingModel model)
|
||||
public void UpdateServices(VetClinicDatabase context, VisitBindingModel model)
|
||||
{
|
||||
var serviceVisits = context.ServiceVisits.Where(rec => rec.VisitId == model.Id).ToList();
|
||||
if (serviceVisits != null)
|
||||
|
@ -11,5 +11,7 @@ namespace VetClinicDataModels.Models
|
||||
int AdminId { get; }
|
||||
string AnimalName { get; }
|
||||
string? Family { get; }
|
||||
}
|
||||
|
||||
Dictionary<int, IVisitModel> VisitAnimals { get; }
|
||||
}
|
||||
}
|
||||
|
@ -11,6 +11,6 @@ namespace VetClinicDataModels.Models
|
||||
string ServiceName { get; }
|
||||
double Price { get; }
|
||||
int PharmacistId { get; }
|
||||
Dictionary<int, (IMedicineModel, int)> ServiceMedicines { get; }
|
||||
Dictionary<int, IMedicineModel> ServiceMedicines { get; }
|
||||
}
|
||||
}
|
||||
|
@ -8,7 +8,6 @@ namespace VetClinicDataModels.Models
|
||||
{
|
||||
public interface IVaccinationModel : IId
|
||||
{
|
||||
int Id { get; }
|
||||
int AnimalId { get; }
|
||||
string NameVaccination { get; }
|
||||
double CostVaccination { get; }
|
||||
|
@ -8,12 +8,9 @@ namespace VetClinicDataModels.Models
|
||||
{
|
||||
public interface IVisitModel : IId
|
||||
{
|
||||
int Id { get;}
|
||||
int AdminId { get; }
|
||||
string NameVisit { get;}
|
||||
DateTime DateVisit { get; }
|
||||
Dictionary<int,IAnimalModel> VisitAnimals { get; }
|
||||
|
||||
Dictionary<int, IServiceModel> ServiceVisits { get; }
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ using VetClinicContracts.BindingModels;
|
||||
using VetClinicContracts.BusinessLogicsContracts;
|
||||
using VetClinicContracts.SearchModels;
|
||||
using VetClinicContracts.ViewModels;
|
||||
using VetClinicDataBaseImplement.Models;
|
||||
|
||||
namespace VetClinicRestApi.Controllers
|
||||
{
|
||||
@ -20,14 +21,16 @@ namespace VetClinicRestApi.Controllers
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public AnimalViewModel? GetAnimal(int animalId)
|
||||
public Tuple<AnimalViewModel, List<string>>? GetAnimal(int animalId)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _animal.ReadElement(new AnimalSearchModel
|
||||
{
|
||||
Id = animalId
|
||||
});
|
||||
var elem = _animal.ReadElement(new AnimalSearchModel { Id = animalId });
|
||||
if (elem == null)
|
||||
return null;
|
||||
var res = Tuple.Create(elem, elem.VisitAnimals.Select(x => x.Value.NameVisit).ToList());
|
||||
res.Item1.VisitAnimals = null;
|
||||
return res;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@ -37,11 +40,14 @@ namespace VetClinicRestApi.Controllers
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public List<AnimalViewModel>? GetAnimalList()
|
||||
public List<AnimalViewModel>? GetAnimalList(int adminId)
|
||||
{
|
||||
try
|
||||
try
|
||||
{
|
||||
return _animal.ReadList(null);
|
||||
var res = _animal.ReadList(new AnimalSearchModel { AdminId = adminId });
|
||||
foreach (var animal in res)
|
||||
animal.VisitAnimals = null;
|
||||
return res;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@ -54,7 +60,7 @@ namespace VetClinicRestApi.Controllers
|
||||
{
|
||||
try
|
||||
{
|
||||
return _animal.CreateAnimal(model);
|
||||
return _animal.Create(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@ -64,11 +70,13 @@ namespace VetClinicRestApi.Controllers
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public bool UpdateAnimal(AnimalBindingModel model)
|
||||
public bool UpdateAnimal(bool isConnection,AnimalBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _animal.UpdateAnimal(model);
|
||||
if (!isConnection)
|
||||
model.VisitAnimals = null!;
|
||||
return _animal.Update(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@ -82,7 +90,7 @@ namespace VetClinicRestApi.Controllers
|
||||
{
|
||||
try
|
||||
{
|
||||
return _animal.DeleteAnimal(model);
|
||||
return _animal.Delete(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
@ -27,7 +27,9 @@ namespace VetClinicRestApi.Controllers
|
||||
var elem = _medicine.ReadElement(new MedicineSearchModel { Id = medicineId });
|
||||
if (elem == null)
|
||||
return null;
|
||||
return Tuple.Create(elem, elem.MedicineAnimals.Select(x => x.Value.AnimalName).ToList());
|
||||
var res = Tuple.Create(elem, elem.MedicineAnimals.Select(x => x.Value.AnimalName).ToList());
|
||||
res.Item1.MedicineAnimals = null;
|
||||
return res;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@ -36,11 +38,14 @@ namespace VetClinicRestApi.Controllers
|
||||
}
|
||||
}
|
||||
[HttpGet]
|
||||
public List<MedicineViewModel> GetMedicines(int pharmacistId)
|
||||
public List<MedicineViewModel>? GetMedicines(int pharmacistId)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _medicine.ReadList(new MedicineSearchModel { PharmacistId = pharmacistId});
|
||||
var res = _medicine.ReadList(new MedicineSearchModel { PharmacistId = pharmacistId });
|
||||
foreach (var medicine in res)
|
||||
medicine.MedicineAnimals = null;
|
||||
return res;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@ -63,11 +68,12 @@ namespace VetClinicRestApi.Controllers
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public bool UpdateMedicine(MedicineBindingModel model)
|
||||
public bool UpdateMedicine(bool isConnection, MedicineBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
model.MedicineAnimals = null!;
|
||||
if (!isConnection)
|
||||
model.MedicineAnimals = null!;
|
||||
return _medicine.Update(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
@ -20,14 +20,14 @@ namespace VetClinicRestApi.Controllers
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public Tuple<ServiceViewModel, List<Tuple<string, int>>>? GetService(int serviceId)
|
||||
public Tuple<ServiceViewModel, List<string>>? GetService(int serviceId)
|
||||
{
|
||||
try
|
||||
{
|
||||
var elem = _service.ReadElement(new ServiceSearchModel { Id = serviceId });
|
||||
if (elem == null)
|
||||
return null;
|
||||
return Tuple.Create(elem, elem.ServiceMedicines.Select(x => Tuple.Create(x.Value.Item1.MedicineName, x.Value.Item2)).ToList());
|
||||
return Tuple.Create(elem, elem.ServiceMedicines.Select(x => x.Value.MedicineName).ToList());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
@ -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 = _visit.ReadElement(new VisitSearchModel { Id = VisitId });
|
||||
if (elem == null)
|
||||
return null;
|
||||
return Tuple.Create(elem, elem.VisitAnimals.Select(x => x.Value.AnimalName).ToList());
|
||||
var res = Tuple.Create(elem, elem.ServiceVisits.Select(x => x.Value.ServiceName).ToList());
|
||||
res.Item1.ServiceVisits = null;
|
||||
return res;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@ -40,11 +43,14 @@ namespace VetClinicRestApi.Controllers
|
||||
{
|
||||
try
|
||||
{
|
||||
return _visit.ReadList(new VisitSearchModel { AdminId = adminId});
|
||||
var res = _visit.ReadList(new VisitSearchModel { AdminId = adminId });
|
||||
foreach (var visit in res)
|
||||
visit.ServiceVisits = null;
|
||||
return res;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка получения списка визитовв");
|
||||
_logger.LogError(ex, "Ошибка получения списка животного");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
@ -63,11 +69,12 @@ namespace VetClinicRestApi.Controllers
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public bool UpdateVisit(VisitBindingModel model)
|
||||
public bool UpdateVisit(bool isConnection,VisitBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
model.VisitAnimals = null!;
|
||||
if (!isConnection)
|
||||
model.ServiceVisits = null!;
|
||||
return _visit.Update(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
Loading…
Reference in New Issue
Block a user