Compare commits
4 Commits
0728fb599c
...
48f2eb83b4
Author | SHA1 | Date | |
---|---|---|---|
|
48f2eb83b4 | ||
|
c6a72b65b7 | ||
|
77484409f6 | ||
|
51b0308ea8 |
@ -1,6 +1,8 @@
|
||||
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;
|
||||
@ -45,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
|
||||
@ -77,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");
|
||||
}
|
||||
@ -98,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
|
||||
@ -117,20 +119,25 @@ View(APIPharmacist.GetRequest<List<MedicineViewModel>>($"api/medicine/getmedicin
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
ViewBag.Animals = APIPharmacist.GetRequest<List<AnimalViewModel>>($"api/animal/getanimallist");
|
||||
|
||||
return View();
|
||||
}
|
||||
|
||||
|
||||
|
||||
[HttpPost]
|
||||
public void CreateMedicine(string name, string price, List<int> animals)
|
||||
public void CreateMedicine(string name, string price)
|
||||
{
|
||||
if (APIPharmacist.Pharmacist == null)
|
||||
{
|
||||
throw new Exception("Âû êàê ñþäà ïîïàëè? Ñþäà âõîä òîëüêî àâòîðèçîâàííûì");
|
||||
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
|
||||
{
|
||||
@ -138,24 +145,18 @@ View(APIPharmacist.GetRequest<List<MedicineViewModel>>($"api/medicine/getmedicin
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
throw new Exception("Îøèáêà â ââåäåííûõ äàííûõ");
|
||||
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);
|
||||
throw new Exception("Ошибка в введенных данных");
|
||||
}
|
||||
|
||||
APIPharmacist.PostRequest("api/medicine/createmedicine", new MedicineBindingModel
|
||||
{
|
||||
MedicineName = name,
|
||||
Price = Math.Round(_price, 2),
|
||||
PharmacistId = APIPharmacist.Pharmacist.Id,
|
||||
MedicineAnimals = a
|
||||
PharmacistId = APIPharmacist.Pharmacist.Id
|
||||
}) ;
|
||||
Response.Redirect("Index");
|
||||
}
|
||||
@ -175,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
|
||||
{
|
||||
@ -191,18 +192,23 @@ View(APIPharmacist.GetRequest<List<MedicineViewModel>>($"api/medicine/getmedicin
|
||||
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)
|
||||
public void UpdateMedicine(int medicine, string name, string price)
|
||||
{
|
||||
if (APIPharmacist.Pharmacist == null)
|
||||
{
|
||||
throw new Exception("Âû êàê ñþäà ïîïàëè? Ñþäà âõîä òîëüêî àâòîðèçîâàííûì");
|
||||
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
|
||||
{
|
||||
@ -210,18 +216,68 @@ View(APIPharmacist.GetRequest<List<MedicineViewModel>>($"api/medicine/getmedicin
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception("Îøèáêà â ââåäåííûõ äàííûõ");
|
||||
throw new Exception("Ошибка в введенных данных");
|
||||
}
|
||||
if (string.IsNullOrEmpty(name) || _price <= 0)
|
||||
{
|
||||
throw new Exception("Îøèáêà â ââåäåííûõ äàííûõ");
|
||||
throw new Exception("Ошибка в введенных данных");
|
||||
}
|
||||
APIPharmacist.PostRequest("api/medicine/updatemedicine?isconnection=false", new MedicineBindingModel
|
||||
{
|
||||
Id = medicine,
|
||||
MedicineName = name,
|
||||
Price = Math.Round(_price, 2),
|
||||
PharmacistId = APIPharmacist.Pharmacist.Id,
|
||||
});
|
||||
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", new MedicineBindingModel
|
||||
APIPharmacist.PostRequest("api/medicine/updatemedicine?isconnection=true", new MedicineBindingModel
|
||||
{
|
||||
Id = medicine,
|
||||
MedicineName = name,
|
||||
@ -243,7 +299,7 @@ View(APIPharmacist.GetRequest<List<MedicineViewModel>>($"api/medicine/getmedicin
|
||||
{
|
||||
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)
|
||||
@ -259,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;
|
||||
//}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -18,17 +18,6 @@
|
||||
<input type="text" name="price" id="price" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Животные:</div>
|
||||
<div class="col-8">
|
||||
<select name="animals" class="form-control" multiple size="6" id="animals">
|
||||
@foreach (var animal in ViewBag.Animals)
|
||||
{
|
||||
<option value="@animal.Id">@animal.AnimalName</option>
|
||||
}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-8"></div>
|
||||
<div class="col-4">
|
||||
|
@ -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>
|
||||
}
|
@ -22,17 +22,6 @@
|
||||
<div class="col-4">Цена:</div>
|
||||
<div class="col-8"><input type="text" id="price" name="price" class="form-control" /></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Животные:</div>
|
||||
<div class="col-8">
|
||||
<select name="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>
|
||||
@ -54,10 +43,6 @@
|
||||
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")
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
|
@ -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'ом уже есть");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
@ -77,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;
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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; }
|
||||
}
|
||||
}
|
||||
|
@ -68,10 +68,12 @@ namespace VetClinicRestApi.Controllers
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public bool UpdateMedicine(MedicineBindingModel model)
|
||||
public bool UpdateMedicine(bool isConnection, MedicineBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
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)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user