Compare commits
3 Commits
48f2eb83b4
...
f09946ecd5
Author | SHA1 | Date | |
---|---|---|---|
|
f09946ecd5 | ||
|
0f1757fc1d | ||
|
62570a8348 |
@ -321,148 +321,270 @@ View(APIPharmacist.GetRequest<List<MedicineViewModel>>($"api/medicine/getmedicin
|
||||
return result;
|
||||
}
|
||||
|
||||
//public IActionResult CreateService()
|
||||
//{
|
||||
// if (APIPharmacist.Pharmacist == null)
|
||||
// {
|
||||
// return Redirect("~/Home/Enter");
|
||||
// }
|
||||
// ViewBag.Medicines = APIPharmacist.GetRequest<List<MedicineViewModel>>($"api/animal/getmedicines");
|
||||
public IActionResult Services()
|
||||
{
|
||||
if (APIPharmacist.Pharmacist == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
return
|
||||
View(APIPharmacist.GetRequest<List<ServiceViewModel>>($"api/service/getservices?pharmacistid={APIPharmacist.Pharmacist.Id}"));
|
||||
|
||||
// return View();
|
||||
//}
|
||||
}
|
||||
|
||||
|
||||
public IActionResult CreateService()
|
||||
{
|
||||
if (APIPharmacist.Pharmacist == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
ViewBag.Medicines = APIPharmacist.GetRequest<List<MedicineViewModel>>($"api/medicine/getmedicines");
|
||||
|
||||
return View();
|
||||
}
|
||||
|
||||
|
||||
|
||||
//[HttpPost]
|
||||
//public void CreateService(string name, string price, List<int> medicines)
|
||||
//{
|
||||
// if (APIPharmacist.Pharmacist == null)
|
||||
// {
|
||||
// throw new Exception("Âû êàê ñþäà ïîïàëè? Ñþäà âõîä òîëüêî àâòîðèçîâàííûì");
|
||||
// }
|
||||
// double _price;
|
||||
// try
|
||||
// {
|
||||
// _price = Convert.ToDouble(price);
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// throw new Exception("Îøèáêà â ââåäåííûõ äàííûõ");
|
||||
// }
|
||||
// if (string.IsNullOrEmpty(name) || _price <= 0)
|
||||
// {
|
||||
// throw new Exception("Îøèáêà â ââåäåííûõ äàííûõ");
|
||||
// }
|
||||
// Dictionary<int, IMedicineModel> a = new Dictionary<int, IMedicineModel>();
|
||||
// foreach (int medicine in medicines)
|
||||
// {
|
||||
// a.Add(medicine, new AnimalSearchModel { Id = medicine } as IMedicineModel);
|
||||
// }
|
||||
[HttpPost]
|
||||
public void CreateService(string name, string price, List<int> medicines)
|
||||
{
|
||||
if (APIPharmacist.Pharmacist == null)
|
||||
{
|
||||
throw new Exception("Âû êàê ñþäà ïîïàëè? Ñþäà âõîä òîëüêî àâòîðèçîâàííûì");
|
||||
}
|
||||
StringBuilder st = new StringBuilder(price);
|
||||
for (int i = 0; i < price.Length; i++)
|
||||
{
|
||||
if (price[i] == '.')
|
||||
st[i] = ',';
|
||||
}
|
||||
price = st.ToString();
|
||||
double _price;
|
||||
try
|
||||
{
|
||||
_price = Convert.ToDouble(price);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception("Îøèáêà â ââåäåííûõ äàííûõ");
|
||||
}
|
||||
if (string.IsNullOrEmpty(name) || _price <= 0)
|
||||
{
|
||||
throw new Exception("Îøèáêà â ââåäåííûõ äàííûõ");
|
||||
}
|
||||
Dictionary<int, IMedicineModel> a = new Dictionary<int, IMedicineModel>();
|
||||
foreach (int medicine in medicines)
|
||||
{
|
||||
a.Add(medicine, new AnimalSearchModel { Id = medicine } as IMedicineModel);
|
||||
}
|
||||
|
||||
// APIPharmacist.PostRequest("api/service/createservice", new ServiceBindingModel
|
||||
// {
|
||||
// ServiceName = name,
|
||||
// Price = Math.Round(_price, 2),
|
||||
// PharmacistId = APIPharmacist.Pharmacist.Id,
|
||||
// ServiceMedicines = a
|
||||
// });
|
||||
// Response.Redirect("Index");
|
||||
//}
|
||||
APIPharmacist.PostRequest("api/service/createservice", new ServiceBindingModel
|
||||
{
|
||||
ServiceName = name,
|
||||
Price = Math.Round(_price, 2),
|
||||
PharmacistId = APIPharmacist.Pharmacist.Id,
|
||||
ServiceMedicines = a
|
||||
});
|
||||
Response.Redirect("Index");
|
||||
}
|
||||
|
||||
//public IActionResult DeleteMedicine()
|
||||
//{
|
||||
// if (APIPharmacist.Pharmacist == null)
|
||||
// {
|
||||
// return Redirect("~/Home/Enter");
|
||||
// }
|
||||
// ViewBag.Medicines = APIPharmacist.GetRequest<List<MedicineViewModel>>($"api/medicine/getmedicines?pharmacistid={APIPharmacist.Pharmacist.Id}");
|
||||
// return View();
|
||||
//}
|
||||
public IActionResult DeleteService()
|
||||
{
|
||||
if (APIPharmacist.Pharmacist == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
ViewBag.Services = APIPharmacist.GetRequest<List<ServiceViewModel>>($"api/service/getservices?pharmacistid={APIPharmacist.Pharmacist.Id}");
|
||||
return View();
|
||||
}
|
||||
|
||||
//[HttpPost]
|
||||
//public void DeleteMedicine(int medicine)
|
||||
//{
|
||||
// if (APIPharmacist.Pharmacist == null)
|
||||
// {
|
||||
// throw new Exception("Âû êàê ñþäà ïîïàëè? Ñþäà âõîä òîëüêî àâòîðèçîâàííûì");
|
||||
// }
|
||||
// APIPharmacist.PostRequest("api/medicine/deletemedicine", new MedicineBindingModel
|
||||
// {
|
||||
// Id = medicine
|
||||
// });
|
||||
// Response.Redirect("Index");
|
||||
//}
|
||||
[HttpPost]
|
||||
public void DeleteService(int service)
|
||||
{
|
||||
if (APIPharmacist.Pharmacist == null)
|
||||
{
|
||||
throw new Exception("Âû êàê ñþäà ïîïàëè? Ñþäà âõîä òîëüêî àâòîðèçîâàííûì");
|
||||
}
|
||||
APIPharmacist.PostRequest("api/service/deleteservice", new ServiceBindingModel
|
||||
{
|
||||
Id = service
|
||||
});
|
||||
Response.Redirect("Index");
|
||||
}
|
||||
|
||||
//public IActionResult UpdateMedicine()
|
||||
//{
|
||||
// if (APIPharmacist.Pharmacist == null)
|
||||
// {
|
||||
// return Redirect("~/Home/Enter");
|
||||
// }
|
||||
// ViewBag.Medicines = APIPharmacist.GetRequest<List<MedicineViewModel>>($"api/medicine/getmedicines?pharmacistid={APIPharmacist.Pharmacist.Id}");
|
||||
// ViewBag.Animals = APIPharmacist.GetRequest<List<AnimalViewModel>>($"api/animal/getanimallist");
|
||||
// return View();
|
||||
//}
|
||||
public IActionResult UpdateService()
|
||||
{
|
||||
if (APIPharmacist.Pharmacist == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
ViewBag.Services = APIPharmacist.GetRequest<List<ServiceViewModel>>($"api/service/getservices?pharmacistid={APIPharmacist.Pharmacist.Id}");
|
||||
ViewBag.Medicines = APIPharmacist.GetRequest<List<MedicineViewModel>>($"api/medicine/getmedicines");
|
||||
return View();
|
||||
}
|
||||
|
||||
//[HttpPost]
|
||||
//public void UpdateMedicine(int medicine, string name, string price,
|
||||
// List<int> animals)
|
||||
//{
|
||||
// if (APIPharmacist.Pharmacist == null)
|
||||
// {
|
||||
// throw new Exception("Âû êàê ñþäà ïîïàëè? Ñþäà âõîä òîëüêî àâòîðèçîâàííûì");
|
||||
// }
|
||||
// double _price;
|
||||
// try
|
||||
// {
|
||||
// _price = Convert.ToDouble(price);
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// throw new Exception("Îøèáêà â ââåäåííûõ äàííûõ");
|
||||
// }
|
||||
// if (string.IsNullOrEmpty(name) || _price <= 0)
|
||||
// {
|
||||
// throw new Exception("Îøèáêà â ââåäåííûõ äàííûõ");
|
||||
// }
|
||||
// Dictionary<int, IAnimalModel> a = new Dictionary<int, IAnimalModel>();
|
||||
// foreach (int animal in animals)
|
||||
// {
|
||||
// a.Add(animal, new AnimalSearchModel { Id = animal } as IAnimalModel);
|
||||
// }
|
||||
// APIPharmacist.PostRequest("api/medicine/updatemedicine", new MedicineBindingModel
|
||||
// {
|
||||
// Id = medicine,
|
||||
// MedicineName = name,
|
||||
// Price = Math.Round(_price, 2),
|
||||
// PharmacistId = APIPharmacist.Pharmacist.Id,
|
||||
// MedicineAnimals = a
|
||||
// });
|
||||
// Response.Redirect("Index");
|
||||
//}
|
||||
[HttpPost]
|
||||
public void UpdateService(int service, string name, string price,
|
||||
List<int> medicines)
|
||||
{
|
||||
if (APIPharmacist.Pharmacist == null)
|
||||
{
|
||||
throw new Exception("Âû êàê ñþäà ïîïàëè? Ñþäà âõîä òîëüêî àâòîðèçîâàííûì");
|
||||
}
|
||||
StringBuilder st = new StringBuilder(price);
|
||||
for (int i = 0; i < price.Length; i++)
|
||||
{
|
||||
if (price[i] == '.')
|
||||
st[i] = ',';
|
||||
}
|
||||
price = st.ToString();
|
||||
double _price;
|
||||
try
|
||||
{
|
||||
_price = Convert.ToDouble(price);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception("Îøèáêà â ââåäåííûõ äàííûõ");
|
||||
}
|
||||
if (string.IsNullOrEmpty(name) || _price <= 0)
|
||||
{
|
||||
throw new Exception("Îøèáêà â ââåäåííûõ äàííûõ");
|
||||
}
|
||||
Dictionary<int, IMedicineModel> a = new Dictionary<int, IMedicineModel>();
|
||||
foreach (int medicine in medicines)
|
||||
{
|
||||
a.Add(medicine, new MedicineSearchModel { Id = medicine } as IMedicineModel);
|
||||
}
|
||||
APIPharmacist.PostRequest("api/service/updateservice", new ServiceBindingModel
|
||||
{
|
||||
Id = service,
|
||||
ServiceName = name,
|
||||
Price = Math.Round(_price, 2),
|
||||
PharmacistId = APIPharmacist.Pharmacist.Id,
|
||||
ServiceMedicines = a
|
||||
});
|
||||
Response.Redirect("Index");
|
||||
}
|
||||
|
||||
//[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
|
||||
//public IActionResult Error()
|
||||
//{
|
||||
// return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
|
||||
//}
|
||||
[HttpGet]
|
||||
public Tuple<ServiceViewModel, List<string>>? GetService(int serviceId)
|
||||
{
|
||||
if (APIPharmacist.Pharmacist == null)
|
||||
{
|
||||
throw new Exception("Âû êàê ñþäà ïîïàëè? Ñþäà âõîä òîëüêî àâòîðèçîâàííûì");
|
||||
}
|
||||
var result = APIPharmacist.GetRequest<Tuple<ServiceViewModel, List<string>>>($"api/service/getservice?serviceid={serviceId}");
|
||||
if (result == null)
|
||||
{
|
||||
return default;
|
||||
}
|
||||
|
||||
//[HttpGet]
|
||||
//public Tuple<MedicineViewModel, List<string>>? GetMedicine(int medicineId)
|
||||
//{
|
||||
// if (APIPharmacist.Pharmacist == null)
|
||||
// {
|
||||
// throw new Exception("Âû êàê ñþäà ïîïàëè? Ñþäà âõîä òîëüêî àâòîðèçîâàííûì");
|
||||
// }
|
||||
// var result = APIPharmacist.GetRequest<Tuple<MedicineViewModel, List<string>>>($"api/medicine/getmedicine?medicineid={medicineId}");
|
||||
// if (result == null)
|
||||
// {
|
||||
// return default;
|
||||
// }
|
||||
return result;
|
||||
}
|
||||
|
||||
// return result;
|
||||
//}
|
||||
public IActionResult Guidances()
|
||||
{
|
||||
if (APIPharmacist.Pharmacist == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
var res = APIPharmacist.GetRequest<List<GuidanceViewModel>>($"api/guidance/getguidances");
|
||||
return
|
||||
View(res);
|
||||
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult CreateGuidance()
|
||||
{
|
||||
ViewBag.Services = APIPharmacist.GetRequest<List<ServiceViewModel>>("api/service/getservices");
|
||||
return View();
|
||||
}
|
||||
[HttpPost]
|
||||
public void CreateGuidance(int service, string text)
|
||||
{
|
||||
if (APIPharmacist.Pharmacist == null)
|
||||
{
|
||||
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
|
||||
}
|
||||
if (string.IsNullOrEmpty(text))
|
||||
{
|
||||
throw new Exception("Рекомендация не может быть пустой");
|
||||
}
|
||||
APIPharmacist.PostRequest("api/guidance/createguidance", new
|
||||
GuidanceBindingModel
|
||||
{
|
||||
ServiceId = service,
|
||||
Text = text,
|
||||
});
|
||||
Response.Redirect("Index");
|
||||
}
|
||||
[HttpGet]
|
||||
public IActionResult UpdateGuidance()
|
||||
{
|
||||
ViewBag.Services = APIPharmacist.GetRequest<List<ServiceViewModel>>("api/service/getservices");
|
||||
ViewBag.Guidances = APIPharmacist.GetRequest<List<GuidanceViewModel>>($"api/guidance/getguidances");
|
||||
return View();
|
||||
}
|
||||
[HttpPost]
|
||||
public void UpdateGuidance(int guidance, int service, string text)
|
||||
{
|
||||
if (APIPharmacist.Pharmacist == null)
|
||||
{
|
||||
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
|
||||
}
|
||||
if (string.IsNullOrEmpty(text))
|
||||
{
|
||||
throw new Exception("Рекомендация не может быть пустой");
|
||||
}
|
||||
APIPharmacist.PostRequest("api/guidance/updateguidance", new
|
||||
GuidanceBindingModel
|
||||
{
|
||||
Id = guidance,
|
||||
ServiceId = service,
|
||||
Text = text,
|
||||
});
|
||||
Response.Redirect("Index");
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult DeleteGuidance()
|
||||
{
|
||||
ViewBag.Guidances = APIPharmacist.GetRequest<List<GuidanceViewModel>>($"api/guidance/getguidances");
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void DeleteGuidance(int guidance)
|
||||
{
|
||||
if (APIPharmacist.Pharmacist == null)
|
||||
{
|
||||
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
|
||||
}
|
||||
APIPharmacist.PostRequest("api/guidance/deleteguidance", new
|
||||
GuidanceBindingModel
|
||||
{
|
||||
Id = guidance
|
||||
});
|
||||
Response.Redirect("Index");
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public GuidanceViewModel GetGuidance(int guidanceId)
|
||||
{
|
||||
if (APIPharmacist.Pharmacist == null)
|
||||
{
|
||||
throw new Exception("Âû êàê ñþäà ïîïàëè? Ñþäà âõîä òîëüêî àâòîðèçîâàííûì");
|
||||
}
|
||||
var result = APIPharmacist.GetRequest<GuidanceViewModel>($"api/guidance/getguidance?guidanceid={guidanceId}");
|
||||
if (result == null)
|
||||
{
|
||||
return default;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
29
VetClinic/PharmacistApp/Views/Home/CreateGuidance.cshtml
Normal file
29
VetClinic/PharmacistApp/Views/Home/CreateGuidance.cshtml
Normal file
@ -0,0 +1,29 @@
|
||||
@{
|
||||
ViewData["Title"] = "CreateGuidance";
|
||||
}
|
||||
|
||||
<div class="text-center">
|
||||
<h2 class="display-4">Создание рекомендации</h2>
|
||||
</div>
|
||||
<form method="post">
|
||||
<div class="row">
|
||||
<div class="col-4">Услуга:</div>
|
||||
<div class="col-8">
|
||||
<select id="service" name="service" class="form-control" asp-items="@(new SelectList(@ViewBag.Services,"Id", "ServiceName"))"></select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Текст:</div>
|
||||
<div class="col-8">
|
||||
<textarea id="text" name="text" rows="5" cols="80">
|
||||
</textarea>
|
||||
</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>
|
39
VetClinic/PharmacistApp/Views/Home/CreateService.cshtml
Normal file
39
VetClinic/PharmacistApp/Views/Home/CreateService.cshtml
Normal file
@ -0,0 +1,39 @@
|
||||
@{
|
||||
ViewData["Title"] = "CreateService";
|
||||
}
|
||||
|
||||
<div class="text-center">
|
||||
<h2 class="display-4">Создание услуги</h2>
|
||||
</div>
|
||||
<form method="post">
|
||||
<div class="row">
|
||||
<div class="col-4">Название:</div>
|
||||
<div class="col-8">
|
||||
<input type="text" name="name" id="name" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Цена:</div>
|
||||
<div class="col-8">
|
||||
<input type="text" name="price" id="price" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Медикаменты:</div>
|
||||
<div class="col-8">
|
||||
<select name="medicines" class="form-control" multiple size="6" id="medicines">
|
||||
@foreach (var medicine in ViewBag.Medicines)
|
||||
{
|
||||
<option value="@medicine.Id">@medicine.MedicineName</option>
|
||||
}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-8"></div>
|
||||
<div class="col-4">
|
||||
<input type="submit" value="Создать" class="btn
|
||||
btn-primary" />
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
18
VetClinic/PharmacistApp/Views/Home/DeleteGuidance.cshtml
Normal file
18
VetClinic/PharmacistApp/Views/Home/DeleteGuidance.cshtml
Normal file
@ -0,0 +1,18 @@
|
||||
@{
|
||||
ViewData["Title"] = "DeleteGuidance";
|
||||
}
|
||||
<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="guidance" name="guidance" class="form-control" asp-items="@(new SelectList(@ViewBag.Guidances, "Id", "Text"))"></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>
|
@ -1,5 +1,5 @@
|
||||
@{
|
||||
ViewData["Title"] = "Delete";
|
||||
ViewData["Title"] = "DeleteMedicine";
|
||||
}
|
||||
<div class="text-center">
|
||||
<h2 class="display-4">Удаление медикамента</h2>
|
||||
|
18
VetClinic/PharmacistApp/Views/Home/DeleteService.cshtml
Normal file
18
VetClinic/PharmacistApp/Views/Home/DeleteService.cshtml
Normal file
@ -0,0 +1,18 @@
|
||||
@{
|
||||
ViewData["Title"] = "DeleteService";
|
||||
}
|
||||
<div class="text-center">
|
||||
<h2 class="display-4">Удаление услуги</h2>
|
||||
</div>
|
||||
<form method="post">
|
||||
<div class="row">
|
||||
<div class="col-4">Услуга:</div>
|
||||
<div class="col-8">
|
||||
<select id="service" name="service" class="form-control" asp-items="@(new SelectList(@ViewBag.Services, "Id", "ServiceName"))"></select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4"></div>
|
||||
<div class="col-8"><input type="submit" value="Удалить" class="btn btn-danger" /></div>
|
||||
</div>
|
||||
</form>s
|
63
VetClinic/PharmacistApp/Views/Home/Guidances.cshtml
Normal file
63
VetClinic/PharmacistApp/Views/Home/Guidances.cshtml
Normal file
@ -0,0 +1,63 @@
|
||||
@using VetClinicContracts.ViewModels
|
||||
@model List<GuidanceViewModel>
|
||||
@{
|
||||
ViewData["Title"] = "Guidances";
|
||||
}
|
||||
<div class="text-center">
|
||||
<h1 class="display-4">Рекомендации</h1>
|
||||
</div>
|
||||
<div class="text-center">
|
||||
@{
|
||||
if (Model == null)
|
||||
{
|
||||
<h3 class="display-4">Авторизируйтесь</h3>
|
||||
return;
|
||||
}
|
||||
<p>
|
||||
<a asp-action="CreateGuidance">Создать рекомендацию</a>
|
||||
<a asp-action="UpdateGuidance">Обновить рекомендацию</a>
|
||||
<a asp-action="DeleteGuidance">Удалить рекомендацию</a>
|
||||
</p>
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
Номер
|
||||
</th>
|
||||
<th>
|
||||
Дата
|
||||
</th>
|
||||
<th>
|
||||
Услуга
|
||||
</th>
|
||||
<th>
|
||||
Текст
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var item in Model)
|
||||
{
|
||||
<tr>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem =>
|
||||
item.Id)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem =>
|
||||
item.Date)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem =>
|
||||
item.ServiceName)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem =>
|
||||
item.Text)
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
}
|
||||
</div>
|
56
VetClinic/PharmacistApp/Views/Home/Services.cshtml
Normal file
56
VetClinic/PharmacistApp/Views/Home/Services.cshtml
Normal file
@ -0,0 +1,56 @@
|
||||
@using VetClinicContracts.ViewModels
|
||||
@model List<ServiceViewModel>
|
||||
@{
|
||||
ViewData["Title"] = "Services";
|
||||
}
|
||||
<div class="text-center">
|
||||
<h1 class="display-4">Услуги</h1>
|
||||
</div>
|
||||
<div class="text-center">
|
||||
@{
|
||||
if (Model == null)
|
||||
{
|
||||
<h3 class="display-4">Авторизируйтесь</h3>
|
||||
return;
|
||||
}
|
||||
<p>
|
||||
<a asp-action="CreateService">Создать услугу</a>
|
||||
<a asp-action="UpdateService">Обновить услугу</a>
|
||||
<a asp-action="DeleteService">Удалить услугу</a>
|
||||
</p>
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
Номер
|
||||
</th>
|
||||
<th>
|
||||
Название
|
||||
</th>
|
||||
<th>
|
||||
Цена
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var item in Model)
|
||||
{
|
||||
<tr>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem =>
|
||||
item.Id)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem =>
|
||||
item.ServiceName)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem =>
|
||||
item.Price)
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
}
|
||||
</div>
|
65
VetClinic/PharmacistApp/Views/Home/UpdateGuidance.cshtml
Normal file
65
VetClinic/PharmacistApp/Views/Home/UpdateGuidance.cshtml
Normal file
@ -0,0 +1,65 @@
|
||||
@{
|
||||
ViewData["Title"] = "UpdateGuidance";
|
||||
}
|
||||
|
||||
<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="guidance" name="guidance" class="form-control" asp-items="@(new SelectList(@ViewBag.Guidances,"Id", "Text"))"></select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Услуга:</div>
|
||||
<div class="col-8">
|
||||
<select name="service" class="form-control" id="service">
|
||||
@foreach (var service in ViewBag.Services)
|
||||
{
|
||||
<option value="@service.Id" id="@service.Id">@service.ServiceName</option>
|
||||
}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Текст:</div>
|
||||
<div class="col-8">
|
||||
<textarea id="text" name="text" rows="5" cols="80">
|
||||
</textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-8"></div>
|
||||
<div class="col-4">
|
||||
<input type="submit" value="Создать" class="btn
|
||||
btn-primary" />
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<script>
|
||||
|
||||
function check() {
|
||||
|
||||
var guidance = $('#guidance').val();
|
||||
$("#service option:selected").removeAttr("selected");
|
||||
if (guidance) {
|
||||
$.ajax({
|
||||
method: "GET",
|
||||
url: "/Home/GetGuidance",
|
||||
data: { guidanceId: guidance },
|
||||
success: function (result) {
|
||||
console.log(result.item2);
|
||||
$('#text').val(result.text);
|
||||
$("#" + result.serviceId).attr("selected", "selected")
|
||||
}
|
||||
|
||||
});
|
||||
};
|
||||
}
|
||||
check();
|
||||
$('#guidance').on('change', function () {
|
||||
check();
|
||||
});
|
||||
</script>
|
71
VetClinic/PharmacistApp/Views/Home/UpdateService.cshtml
Normal file
71
VetClinic/PharmacistApp/Views/Home/UpdateService.cshtml
Normal file
@ -0,0 +1,71 @@
|
||||
@using VetClinicContracts.ViewModels;
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "UpdateService";
|
||||
}
|
||||
|
||||
<div class="text-center">
|
||||
<h2 class="display-4">Редактирование услуги</h2>
|
||||
</div>
|
||||
<form method="post">
|
||||
<div class="row">
|
||||
<div class="col-4">Услуга:</div>
|
||||
<div class="col-8">
|
||||
<select id="service" name="service" class="form-control" asp-items="@(new SelectList(@ViewBag.Services, "Id", "ServiceName"))"></select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Название:</div>
|
||||
<div class="col-8"><input type="text" name="name" id="name" class="form-control" /></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Цена:</div>
|
||||
<div class="col-8"><input type="text" id="price" name="price" class="form-control" /></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Медикаменты:</div>
|
||||
<div class="col-8">
|
||||
<select name="medicines" class="form-control" multiple size="5" id="medicines">
|
||||
@foreach (var medicine in ViewBag.Medicines)
|
||||
{
|
||||
<option value="@medicine.Id" id="@medicine.MedicineName">@medicine.MedicineName</option>
|
||||
}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-8"></div>
|
||||
<div class="col-4"><input type="submit" value="Сохранить" class="btn btn-primary" /></div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
@section Scripts
|
||||
{
|
||||
<script>
|
||||
function check() {
|
||||
var service = $('#service').val();
|
||||
$("#medicines option:selected").removeAttr("selected");
|
||||
if (service) {
|
||||
$.ajax({
|
||||
method: "GET",
|
||||
url: "/Home/GetService",
|
||||
data: { serviceId: service },
|
||||
success: function (result) {
|
||||
console.log(result.item2);
|
||||
$('#name').val(result.item1.serviceName);
|
||||
$('#price').val(result.item1.price);
|
||||
$.map(result.item2, function ( n ) {
|
||||
console.log("#" + n);
|
||||
$("#" + n).attr("selected", "selected")
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
};
|
||||
}
|
||||
check();
|
||||
$('#service').on('change', function () {
|
||||
check();
|
||||
});
|
||||
</script>
|
||||
}
|
@ -3,7 +3,7 @@
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>@ViewData["Title"] - IceCreamShopClientApp</title>
|
||||
<title>@ViewData["Title"] - PharmacistApp </title>
|
||||
<link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.min.css" />
|
||||
<link rel="stylesheet" href="~/css/site.css" />
|
||||
<script src="~/lib/jquery/dist/jquery.min.js"></script>
|
||||
@ -13,7 +13,7 @@
|
||||
<header>
|
||||
<nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bgwhite border-bottom box-shadow mb-3">
|
||||
<div class="container">
|
||||
<a class="navbar-brand" asp-area="" asp-controller="Home" aspaction="Index">Магазин мороженного</a>
|
||||
<a class="navbar-brand" asp-area="" asp-controller="Home" aspaction="Index">Ветклиника</a>
|
||||
<button class="navbar-toggler" type="button" datatoggle="collapse" data-target=".navbar-collapse" ariacontrols="navbarSupportedContent"
|
||||
aria-expanded="false" aria-label="Toggle navigation">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
@ -23,6 +23,12 @@
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="Index">Медикаменты</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="Services">Услуги</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="Guidances">Рекомендации</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="Privacy">Личные данные</a>
|
||||
</li>
|
||||
@ -44,7 +50,7 @@
|
||||
</div>
|
||||
<footer class="border-top footer text-muted">
|
||||
<div class="container">
|
||||
© 2024 - Магазин мороженного - <a asp-area="" aspcontroller="Home" asp-action="Privacy">Личные данные</a>
|
||||
© 2024 - Ветклиника - <a asp-area="" aspcontroller="Home" asp-action="Privacy">Личные данные</a>
|
||||
</div>
|
||||
</footer>
|
||||
<script src="~/js/site.js" asp-append-version="true"></script>
|
||||
|
@ -11,7 +11,7 @@ namespace VetClinicContracts.BindingModels
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Text { get; set; } = string.Empty;
|
||||
public DateTime Date { get; set; }
|
||||
public DateTime Date { get; set; } = DateTime.Now;
|
||||
public int ServiceId { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -33,7 +33,8 @@ namespace VetClinicDataBaseImplement.Implements
|
||||
{
|
||||
using var context = new VetClinicDatabase();
|
||||
return context.Guidances.Include(x => x.Service).FirstOrDefault(x => (!model.Id.HasValue || model.Id == x.Id)
|
||||
&& (!model.ServiceId.HasValue || model.ServiceId == x.ServiceId) && (!model.DateFrom.HasValue || model.DateFrom <= x.Date)
|
||||
&& (!model.ServiceId.HasValue || model.ServiceId == x.ServiceId) && (string.IsNullOrEmpty(model.Text) || model.Text == x.Text)
|
||||
&& (!model.DateFrom.HasValue || model.DateFrom <= x.Date)
|
||||
&& (!model.DateTo.HasValue || model.DateTo >= x.Date))?.GetViewModel;
|
||||
}
|
||||
public GuidanceViewModel? Insert(GuidanceBindingModel model)
|
||||
@ -51,21 +52,20 @@ namespace VetClinicDataBaseImplement.Implements
|
||||
public GuidanceViewModel? Update(GuidanceBindingModel model)
|
||||
{
|
||||
using var context = new VetClinicDatabase();
|
||||
var element = context.Guidances
|
||||
.Include(x => x.Service)
|
||||
.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
if (element != null)
|
||||
var order = context.Guidances.Include(x => x.Service).FirstOrDefault(x => x.Id ==
|
||||
model.Id);
|
||||
if (order == null)
|
||||
{
|
||||
context.Guidances.Remove(element);
|
||||
context.SaveChanges();
|
||||
return element.GetViewModel;
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
order.Update(context, model);
|
||||
context.SaveChanges();
|
||||
return order.GetViewModel;
|
||||
}
|
||||
public GuidanceViewModel? Delete(GuidanceBindingModel model)
|
||||
{
|
||||
using var context = new VetClinicDatabase();
|
||||
var element = context.Guidances.FirstOrDefault(rec => rec.Id ==
|
||||
var element = context.Guidances.Include(x => x.Service).FirstOrDefault(rec => rec.Id ==
|
||||
model.Id);
|
||||
if (element != null)
|
||||
{
|
||||
|
@ -36,7 +36,7 @@ namespace VetClinicDataBaseImplement.Models
|
||||
};
|
||||
}
|
||||
|
||||
public void Update(GuidanceBindingModel? model)
|
||||
public void Update(VetClinicDatabase context, GuidanceBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
@ -44,6 +44,8 @@ namespace VetClinicDataBaseImplement.Models
|
||||
}
|
||||
Text = model.Text;
|
||||
Date = model.Date;
|
||||
ServiceId = model.ServiceId;
|
||||
Service = context.Services.FirstOrDefault(x => x.Id == model.ServiceId);
|
||||
}
|
||||
|
||||
public GuidanceViewModel GetViewModel => new()
|
||||
|
@ -52,6 +52,8 @@ namespace VetClinicDataBaseImplement.Models
|
||||
Id = model.Id,
|
||||
ServiceName = model.ServiceName,
|
||||
Price = model.Price,
|
||||
PharmacistId = model.PharmacistId,
|
||||
Pharmacist = context.Pharmacists.First(x => x.Id == model.PharmacistId),
|
||||
Medicines = model.ServiceMedicines.Select(x => new
|
||||
ServiceMedicine
|
||||
{
|
||||
|
@ -21,12 +21,29 @@ namespace VetClinicRestApi.Controllers
|
||||
_logger = logger;
|
||||
_guidance = guidance;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public List<GuidanceViewModel>? GetGuidances(int serviceId)
|
||||
public GuidanceViewModel GetGuidance(int guidanceId)
|
||||
{
|
||||
try
|
||||
{
|
||||
var elem = _guidance.ReadElement(new GuidanceSearchModel { Id = guidanceId });
|
||||
if (elem == null)
|
||||
return null;
|
||||
return elem;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка получения рекомендации по id={Id}", guidanceId);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
[HttpGet]
|
||||
public List<GuidanceViewModel>? GetGuidances(int? serviceId = null)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!serviceId.HasValue)
|
||||
return _guidance.ReadList(null);
|
||||
return _guidance.ReadList(new GuidanceSearchModel
|
||||
{
|
||||
ServiceId = serviceId
|
||||
|
@ -4,6 +4,7 @@ using VetClinicContracts.BindingModels;
|
||||
using VetClinicContracts.BusinessLogicsContracts;
|
||||
using VetClinicContracts.SearchModels;
|
||||
using VetClinicContracts.ViewModels;
|
||||
using VetClinicDataBaseImplement.Models;
|
||||
|
||||
namespace VetClinicRestApi.Controllers
|
||||
{
|
||||
@ -28,7 +29,7 @@ namespace VetClinicRestApi.Controllers
|
||||
if (elem == null)
|
||||
return null;
|
||||
var res = Tuple.Create(elem, elem.MedicineAnimals.Select(x => x.Value.AnimalName).ToList());
|
||||
res.Item1.MedicineAnimals = null;
|
||||
res.Item1.MedicineAnimals = null!;
|
||||
return res;
|
||||
}
|
||||
catch (Exception ex)
|
||||
@ -38,11 +39,15 @@ namespace VetClinicRestApi.Controllers
|
||||
}
|
||||
}
|
||||
[HttpGet]
|
||||
public List<MedicineViewModel>? GetMedicines(int pharmacistId)
|
||||
public List<MedicineViewModel>? GetMedicines(int? pharmacistId = null)
|
||||
{
|
||||
try
|
||||
{
|
||||
var res = _medicine.ReadList(new MedicineSearchModel { PharmacistId = pharmacistId });
|
||||
List<MedicineViewModel> res;
|
||||
if (!pharmacistId.HasValue)
|
||||
res = _medicine.ReadList(null);
|
||||
else
|
||||
res = _medicine.ReadList(new MedicineSearchModel { PharmacistId = pharmacistId });
|
||||
foreach (var medicine in res)
|
||||
medicine.MedicineAnimals = null;
|
||||
return res;
|
||||
|
@ -4,6 +4,7 @@ using VetClinicContracts.BindingModels;
|
||||
using VetClinicContracts.BusinessLogicsContracts;
|
||||
using VetClinicContracts.SearchModels;
|
||||
using VetClinicContracts.ViewModels;
|
||||
using VetClinicDataBaseImplement.Models;
|
||||
|
||||
namespace VetClinicRestApi.Controllers
|
||||
{
|
||||
@ -27,7 +28,9 @@ namespace VetClinicRestApi.Controllers
|
||||
var elem = _service.ReadElement(new ServiceSearchModel { Id = serviceId });
|
||||
if (elem == null)
|
||||
return null;
|
||||
return Tuple.Create(elem, elem.ServiceMedicines.Select(x => x.Value.MedicineName).ToList());
|
||||
var res = Tuple.Create(elem, elem.ServiceMedicines.Select(x => x.Value.MedicineName).ToList());
|
||||
res.Item1.ServiceMedicines = null!;
|
||||
return res;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@ -36,11 +39,18 @@ namespace VetClinicRestApi.Controllers
|
||||
}
|
||||
}
|
||||
[HttpGet]
|
||||
public List<ServiceViewModel> GetServices(int pharmacistId)
|
||||
public List<ServiceViewModel> GetServices(int? pharmacistId = null)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _service.ReadList(new ServiceSearchModel { PharmacistId = pharmacistId });
|
||||
List<ServiceViewModel> res;
|
||||
if (!pharmacistId.HasValue)
|
||||
res = _service.ReadList(null);
|
||||
else
|
||||
res = _service.ReadList(new ServiceSearchModel { PharmacistId = pharmacistId });
|
||||
foreach (var service in res)
|
||||
service.ServiceMedicines = null;
|
||||
return res;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@ -67,7 +77,6 @@ namespace VetClinicRestApi.Controllers
|
||||
{
|
||||
try
|
||||
{
|
||||
model.ServiceMedicines = null!;
|
||||
return _service.Update(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
Loading…
Reference in New Issue
Block a user