Compare commits
No commits in common. "99ca054c53c0880f92bfbff0ec30cb66d55116b1" and "0f1f2d4f183d95757f695633e19af8525346a3f2" have entirely different histories.
99ca054c53
...
0f1f2d4f18
@ -6,7 +6,6 @@ using VetClinicContracts.ViewModels;
|
||||
using VetClinicDataModels.Models;
|
||||
using System.Text;
|
||||
using VetClinicContracts.SearchModels;
|
||||
using System.IO.Pipelines;
|
||||
|
||||
|
||||
namespace VetClinicAdminApp.Controllers
|
||||
@ -19,17 +18,7 @@ namespace VetClinicAdminApp.Controllers
|
||||
{
|
||||
_logger = logger;
|
||||
}
|
||||
[HttpGet]
|
||||
public IActionResult ServiceListReport()
|
||||
{
|
||||
ViewBag.Animals = APIAdmin.GetRequest<List<AnimalViewModel>>($"api/animal/getanimallist?adminid={APIAdmin.Admin.Id}");
|
||||
return View();
|
||||
}
|
||||
[HttpGet]
|
||||
public IActionResult Report()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
public IActionResult Index()
|
||||
{
|
||||
if (APIAdmin.Admin == null)
|
||||
@ -57,7 +46,7 @@ View(APIAdmin.GetRequest<List<AnimalViewModel>>($"api/animal/getanimallist?admin
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
return
|
||||
View(APIAdmin.GetRequest<List<VaccinationViewModel>>($"api/vaccination/getvaccinations?adminId={APIAdmin.Admin.Id}"));
|
||||
View(APIAdmin.GetRequest<List<VaccinationViewModel>>($"api/vaccination/getvaccinations?vaccinationId={APIAdmin.Admin.Id}"));
|
||||
|
||||
}
|
||||
|
||||
@ -148,7 +137,6 @@ View(APIAdmin.GetRequest<List<VaccinationViewModel>>($"api/vaccination/getvaccin
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
ViewBag.Services = APIAdmin.GetRequest<List<ServiceViewModel>>($"api/service/getservices");
|
||||
return View();
|
||||
}
|
||||
public IActionResult CreateAnimal()
|
||||
@ -157,12 +145,11 @@ View(APIAdmin.GetRequest<List<VaccinationViewModel>>($"api/vaccination/getvaccin
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
ViewBag.Services = APIAdmin.GetRequest<List<ServiceViewModel>>($"api/service/getservices?adminid={APIAdmin.Admin.Id}");
|
||||
return View();
|
||||
}
|
||||
public IActionResult CreateVaccination()
|
||||
{
|
||||
ViewBag.Animals = APIAdmin.GetRequest<List<AnimalViewModel>>($"api/animal/getanimallist?adminid={APIAdmin.Admin.Id}");
|
||||
ViewBag.Animals = APIAdmin.GetRequest<List<AnimalViewModel>>("api/animal/getanimallist");
|
||||
return View();
|
||||
}
|
||||
|
||||
@ -205,7 +192,7 @@ View(APIAdmin.GetRequest<List<VaccinationViewModel>>($"api/vaccination/getvaccin
|
||||
Response.Redirect("IndexAnimals");
|
||||
}
|
||||
[HttpPost]
|
||||
public void CreateVaccination(int animale, string name, string cost,DateTime date)
|
||||
public void CreateVaccination(int animale, string name, double cost,DateTime date)
|
||||
{
|
||||
if (APIAdmin.Admin == null)
|
||||
{
|
||||
@ -215,35 +202,15 @@ View(APIAdmin.GetRequest<List<VaccinationViewModel>>($"api/vaccination/getvaccin
|
||||
{
|
||||
throw new Exception("Ошибка в введенных данных");
|
||||
}
|
||||
StringBuilder st = new StringBuilder(cost);
|
||||
for (int i = 0; i < cost.Length; i++)
|
||||
{
|
||||
if (cost[i] == '.')
|
||||
st[i] = ',';
|
||||
}
|
||||
cost = st.ToString();
|
||||
double _cost;
|
||||
try
|
||||
{
|
||||
_cost = Convert.ToDouble(cost);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception("Ошибка в введенных данных");
|
||||
}
|
||||
if (_cost <= 0)
|
||||
if (cost <= 0)
|
||||
{
|
||||
throw new Exception("Цена должна быть выше 0");
|
||||
}
|
||||
if (date == null)
|
||||
{
|
||||
throw new Exception("Выберите дату");
|
||||
}
|
||||
APIAdmin.PostRequest("api/vaccination/createvaccination", new VaccinationBindingModel
|
||||
{
|
||||
NameVaccination = name,
|
||||
AnimalId = animale,
|
||||
CostVaccination = Math.Round(_cost, 2),
|
||||
CostVaccination = cost,
|
||||
DateStamp = date
|
||||
});
|
||||
Response.Redirect("IndexVaccinations");
|
||||
@ -325,8 +292,7 @@ View(APIAdmin.GetRequest<List<VaccinationViewModel>>($"api/vaccination/getvaccin
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
ViewBag.Visits = APIAdmin.GetRequest<List<VisitViewModel>>($"api/visit/getvisits?pharmacistid={APIAdmin.Admin.Id}");
|
||||
ViewBag.Services = APIAdmin.GetRequest<List<ServiceViewModel>>($"api/service/getservices");
|
||||
ViewBag.Visits = APIAdmin.GetRequest<List<VisitViewModel>>("api/visit/getvisits");
|
||||
return View();
|
||||
}
|
||||
|
||||
@ -356,7 +322,6 @@ View(APIAdmin.GetRequest<List<VaccinationViewModel>>($"api/vaccination/getvaccin
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
ViewBag.Animals = APIAdmin.GetRequest<List<AnimalViewModel>>($"api/animal/getanimallist?adminid={APIAdmin.Admin.Id}");
|
||||
|
||||
return View();
|
||||
}
|
||||
|
||||
@ -464,7 +429,6 @@ View(APIAdmin.GetRequest<List<VaccinationViewModel>>($"api/vaccination/getvaccin
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
ViewBag.Vaccinations = APIAdmin.GetRequest<List<VaccinationViewModel>>($"api/vaccination/getvaccinations?adminid={APIAdmin.Admin.Id}");
|
||||
ViewBag.Animals = APIAdmin.GetRequest<List<AnimalViewModel>>($"api/animal/getanimallist?adminid={APIAdmin.Admin.Id}");
|
||||
return View();
|
||||
}
|
||||
|
||||
|
@ -16,18 +16,7 @@
|
||||
<div class="row">
|
||||
<div class="col-4">Дата:</div>
|
||||
<div class="col-8">
|
||||
<input type="date" id="date" name="date" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Услуги:</div>
|
||||
<div class="col-8">
|
||||
<select name="services" class="form-control" multiple size="6" id="services">
|
||||
@foreach (var service in ViewBag.Services)
|
||||
{
|
||||
<option value="@service.Id">@service.ServiceName</option>
|
||||
}
|
||||
</select>
|
||||
<input type="datetime" id="datetime" name="date" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
|
@ -20,6 +20,7 @@
|
||||
<p>
|
||||
<a asp-action="Update">Редактировать визит</a>
|
||||
<a asp-action="Delete">Удалить визит</a>
|
||||
<a asp-action="ServiceVisits">Связать визит и услуги</a>
|
||||
</p>
|
||||
<p>
|
||||
<a asp-action="Create">Создать визит</a>
|
||||
|
@ -1,59 +0,0 @@
|
||||
@{
|
||||
ViewData["Title"] = "Report";
|
||||
}
|
||||
<div class="text-center">
|
||||
<h1 class="display-4">Список визитов с расшифровкой по медикаментам и прививкам</h1>
|
||||
</div>
|
||||
<div class="text-center">
|
||||
@{
|
||||
// if (Model == null)
|
||||
// {
|
||||
// <h3 class="display-4">Авторизируйтесь!</h3>
|
||||
// return;
|
||||
// }
|
||||
<div class="row mb-5">
|
||||
<div class="col-4">Начальная дата:</div>
|
||||
<div class="col-8">
|
||||
<input type="date" id="startDate" name="startDate" class="form-control">
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-5">
|
||||
<div class="col-4">Конечная дата:</div>
|
||||
<div class="col-8">
|
||||
<input type="date" id="endDate" name="endDate" class="form-control">
|
||||
</div>
|
||||
</div>
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
Номер
|
||||
</th>
|
||||
<th>
|
||||
Дата
|
||||
</th>
|
||||
<th>
|
||||
Визит
|
||||
</th>
|
||||
<th>
|
||||
Медикамент
|
||||
</th>
|
||||
<th>
|
||||
Прививка
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
будет заполняться вьюшками отчета
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="row">
|
||||
<div class="col-8"></div>
|
||||
<div class="col-4"><input type="submit" value="Создать отчет" class="btn btn-primary" /></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-8"></div>
|
||||
<div class="col-4"><input type="submit" value="Отправить на почту" class="btn btn-primary" /></div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
@ -1,30 +0,0 @@
|
||||
@using VetClinicContracts.ViewModels;
|
||||
|
||||
@{
|
||||
|
||||
ViewData["Title"] = "ServiceListReport";
|
||||
}
|
||||
|
||||
<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 name="animals" class="form-control" multiple size="5" 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"><input type="submit" value="Word" class="btn btn-primary" /></div>
|
||||
<div class="col-4"><input type="submit" value="Excel" class="btn btn-primary" /></div>
|
||||
</div>
|
||||
</form>
|
65
VetClinic/VetClinicAdminApi/Views/Home/ServiceVisits.cshtml
Normal file
65
VetClinic/VetClinicAdminApi/Views/Home/ServiceVisits.cshtml
Normal file
@ -0,0 +1,65 @@
|
||||
@using VetClinicContracts.ViewModels;
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "ServiceVisits";
|
||||
}
|
||||
|
||||
<div class="text-center">
|
||||
<h2 class="display-4">Связывание визита и услуги</h2>
|
||||
</div>
|
||||
<form method="post">
|
||||
<div class="row">
|
||||
<div class="col-4">Визит:</div>
|
||||
<div class="col-8">
|
||||
<select id="visit" name="visit" class="form-control" asp-items="@(new SelectList(@ViewBag.Visits, "Id", "NameVisit"))"></select>
|
||||
</div>
|
||||
</div>
|
||||
<input style = "visibility: hidden" type="text" name="name" id="name" class="form-control" />
|
||||
<input style="visibility: hidden" type="datetime" id="datetime" name="date" class="form-control" />
|
||||
<div class="row">
|
||||
<div class="col-4">Услуги:</div>
|
||||
<div class="col-8">
|
||||
<select name="services" class="form-control" multiple size="5" id="services">
|
||||
@foreach (var service in ViewBag.Services)
|
||||
{
|
||||
<option value="@service.Id" id="@service.ServicesName">@service.ServicesName</option>
|
||||
}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-8"></div>
|
||||
<div class="col-4"><input type="submit" value="Сохранить" class="btn btn-primary" /></div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
@section Scripts
|
||||
{
|
||||
<script>
|
||||
function check() {
|
||||
var animal = $('#visit').val();
|
||||
$("#services option:selected").removeAttr("selected");
|
||||
if (animal) {
|
||||
$.ajax({
|
||||
method: "GET",
|
||||
url: "/Home/GetVisit",
|
||||
data: { animalId: animal },
|
||||
success: function (result) {
|
||||
console.log(result.item2);
|
||||
$('#name').val(result.item1.visitName);
|
||||
$('#date').val(result.item1.date);
|
||||
$.map(result.item2, function (n) {
|
||||
console.log("#" + n);
|
||||
$("#" + n).attr("selected", "selected")
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
};
|
||||
}
|
||||
check();
|
||||
$('#visit').on('change', function () {
|
||||
check();
|
||||
});
|
||||
</script>
|
||||
}
|
@ -22,21 +22,11 @@
|
||||
<div class="row">
|
||||
<div class="col-4">Дата:</div>
|
||||
<div class="col-8">
|
||||
<input type="date" id="date" name="date" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Услуги:</div>
|
||||
<div class="col-8">
|
||||
<select name="services" class="form-control" multiple size="5" id="services">
|
||||
@foreach (var services in ViewBag.Services)
|
||||
{
|
||||
<option value="@services.Id" data-name="@services.ServiceName">@services.ServiceName</option>
|
||||
}
|
||||
</select>
|
||||
<input type="datetime" id="datetime" name="date" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="row">
|
||||
<div class="col-8"></div>
|
||||
<div class="col-4"><input type="submit" value="Сохранить" class="btn btn-primary" /></div>
|
||||
@ -56,10 +46,6 @@
|
||||
success: function (result) {
|
||||
$('#name').val(result.item1.vistName);
|
||||
$('#date').val(result.item1.date);
|
||||
$.map(result.item2, function (n) {
|
||||
console.log("#" + n);
|
||||
$(`option[data-name=${n}]`).attr("selected", "selected")
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
@ -43,7 +43,7 @@
|
||||
data: { animalId: animal },
|
||||
success: function (result) {
|
||||
$('#name').val(result.item1.animalName);
|
||||
$('#family').val(result.item1.family);
|
||||
$('#family').val(result.item1.price);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
@ -12,17 +12,6 @@
|
||||
<select id="vaccination" name="vaccination" class="form-control" asp-items="@(new SelectList(@ViewBag.Vaccinations, "Id", "NameVaccination"))"></select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Животное:</div>
|
||||
<div class="col-8">
|
||||
<select name="animal" class="form-control" id="animal">
|
||||
@foreach (var animal in ViewBag.Animals)
|
||||
{
|
||||
<option value="@animal.Id" id="@animal.Id">@animal.AnimalName</option>
|
||||
}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Название:</div>
|
||||
<div class="col-8">
|
||||
@ -55,20 +44,13 @@
|
||||
if (snack) {
|
||||
$.ajax({
|
||||
method: "POST",
|
||||
url: "/Home/GetVaccination",
|
||||
data: { vaccinationId: vaccinationId },
|
||||
url: "/Home/GetAnimal",
|
||||
data: { animal: animal },
|
||||
success: function (result) {
|
||||
$('#name').val(result.text);
|
||||
$('#cost').val(result.text);
|
||||
$('#date').val(result.date);
|
||||
$(`option[data-name=${result.animalId}]`).attr("selected", "selected")
|
||||
$("#animal").val(result);
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
check();
|
||||
$('#vaccination').on('change', function () {
|
||||
check();
|
||||
});
|
||||
</script>
|
||||
|
||||
|
@ -22,7 +22,7 @@
|
||||
<select name="visits" class="form-control" multiple size="5" id="visits">
|
||||
@foreach (var visit in ViewBag.Visits)
|
||||
{
|
||||
<option value="@visit.Id" data-name="@visit.NameVisit">@visit.NameVisit</option>
|
||||
<option value="@visit.Id" id="@visit.NameVisit">@visit.NameVisit</option>
|
||||
}
|
||||
</select>
|
||||
</div>
|
||||
|
@ -32,12 +32,6 @@
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="Privacy">Личные данные</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="ServiceListReport">Выгрузка списка</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="Report">Отчет</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="Enter">Вход</a>
|
||||
</li>
|
||||
|
@ -17,49 +17,49 @@ namespace VetClinicBusinessLogic.BusinessLogics
|
||||
{
|
||||
private readonly IServiceStorage _serviceStorage;
|
||||
private readonly IMedicineStorage _medicineStorage;
|
||||
private readonly IAnimalStorage _animalStorage;
|
||||
private readonly AbstractSaveToExcelPharmacist _saveToExcel;
|
||||
private readonly AbstractSaveToWordPharmacist _saveToWord;
|
||||
public ReportLogicPharmacist(IServiceStorage serviceStorage, IMedicineStorage medicineStorage,
|
||||
public ReportLogicPharmacist(IServiceStorage serviceStorage, IMedicineStorage medicineStorage, IAnimalStorage animalStorage,
|
||||
AbstractSaveToExcelPharmacist saveToExcel, AbstractSaveToWordPharmacist saveToWord)
|
||||
{
|
||||
_serviceStorage = serviceStorage;
|
||||
_medicineStorage = medicineStorage;
|
||||
_animalStorage = animalStorage;
|
||||
_saveToExcel = saveToExcel;
|
||||
_saveToWord = saveToWord;
|
||||
}
|
||||
|
||||
public List<ListAnimalsViewModel> GetServiceAnimals(List<int> services)
|
||||
{
|
||||
|
||||
List<ListAnimalsViewModel> ans = new();
|
||||
List<Tuple<ServiceViewModel, List<Tuple<MedicineViewModel, List<AnimalViewModel>>>>> response =
|
||||
_serviceStorage.GetReportInfo(new ListAnimalsSearchModel { servicesIds = services});
|
||||
|
||||
foreach (var service in response)
|
||||
foreach(var service in services)
|
||||
{
|
||||
Dictionary<int, (AnimalViewModel, int)> counter = new();
|
||||
foreach (var medicine in service.Item2)
|
||||
var medicines = _medicineStorage.GetFilteredList(new MedicineSearchModel { ServiceId = service });
|
||||
Dictionary<int, int> counter = new();
|
||||
foreach(var medicine in medicines)
|
||||
{
|
||||
foreach (var animal in medicine.Item2)
|
||||
var animals = _animalStorage.GetFilteredList(new AnimalSearchModel { MedicineId = medicine.Id });
|
||||
foreach(var animal in animals)
|
||||
{
|
||||
if (!counter.ContainsKey(animal.Id))
|
||||
counter.Add(animal.Id, (animal, 1));
|
||||
counter.Add(animal.Id, 1);
|
||||
else
|
||||
{
|
||||
counter[animal.Id] = (counter[animal.Id].Item1, counter[animal.Id].Item2 + 1);
|
||||
counter[animal.Id]++;
|
||||
}
|
||||
}
|
||||
}
|
||||
List<AnimalViewModel> res = new();
|
||||
foreach (var cnt in counter)
|
||||
foreach(var cnt in counter)
|
||||
{
|
||||
if (cnt.Value.Item2 != service.Item2.Count)
|
||||
if (cnt.Value != medicines.Count)
|
||||
continue;
|
||||
res.Add(cnt.Value.Item1);
|
||||
res.Add(_animalStorage.GetElement(new AnimalSearchModel { Id = cnt.Key }));
|
||||
}
|
||||
ans.Add(new ListAnimalsViewModel
|
||||
{
|
||||
ServiceName = service.Item1.ServiceName,
|
||||
ServiceName = _serviceStorage.GetElement(new ServiceSearchModel { Id = service}).ServiceName,
|
||||
Animals = res
|
||||
});
|
||||
}
|
||||
|
@ -1,16 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace VetClinicContracts.BindingModels
|
||||
{
|
||||
public class VisitsGuidesBindingModel
|
||||
{
|
||||
public string FileName { get; set; } = string.Empty;
|
||||
public List<int> Medicines { get; set; } = new();
|
||||
DateTime DateFrom { get; set; } = DateTime.Now;
|
||||
DateTime DateTo { get; set; } = DateTime.Now;
|
||||
}
|
||||
}
|
@ -1,13 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace VetClinicContracts.SearchModels
|
||||
{
|
||||
public class ListAnimalsSearchModel
|
||||
{
|
||||
public List<int>? servicesIds { get; set; }
|
||||
}
|
||||
}
|
@ -11,5 +11,6 @@ namespace VetClinicContracts.SearchModels
|
||||
public int? Id { get; set; }
|
||||
public string? MedicineName { get; set; } = string.Empty;
|
||||
public int? PharmacistId { get; set; }
|
||||
public int? ServiceId { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -11,5 +11,6 @@ namespace VetClinicContracts.SearchModels
|
||||
public int? Id { get; set; }
|
||||
public string? ServiceName { get; set; } = string.Empty;
|
||||
public int? PharmacistId { get; set; }
|
||||
public int? MedicineId { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,6 @@ namespace VetClinicContracts.SearchModels
|
||||
public class VaccinationSearchModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public int? AdminId { get; set; }
|
||||
public string? NameVaccination { get; set; }
|
||||
public double? CostVaccination { get; set; }
|
||||
|
||||
|
@ -1,15 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace VetClinicContracts.SearchModels
|
||||
{
|
||||
public class VisitGuidesSearchModel
|
||||
{
|
||||
public List<int>? medicinesIds { get; set; }
|
||||
public DateTime? DateFrom { get; set; }
|
||||
public DateTime? DateTo { get; set; }
|
||||
}
|
||||
}
|
@ -17,8 +17,5 @@ namespace VetClinicContracts.StoragesContracts
|
||||
MedicineViewModel? Insert(MedicineBindingModel model);
|
||||
MedicineViewModel? Update(MedicineBindingModel model);
|
||||
MedicineViewModel? Delete(MedicineBindingModel model);
|
||||
List<Tuple<MedicineViewModel, List<Tuple<ServiceViewModel, List<GuidanceViewModel>>>>> GetGuidancesInfo(VisitGuidesSearchModel model);
|
||||
List<Tuple<MedicineViewModel, List<Tuple<ServiceViewModel, List<VisitViewModel>>>>> GetVisitsInfo(VisitGuidesSearchModel model);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -13,11 +13,9 @@ namespace VetClinicContracts.StoragesContracts
|
||||
{
|
||||
List<ServiceViewModel> GetFullList();
|
||||
List<ServiceViewModel> GetFilteredList(ServiceSearchModel model);
|
||||
List<Tuple<ServiceViewModel, List<Tuple<MedicineViewModel, List<AnimalViewModel>>>>> GetReportInfo(ListAnimalsSearchModel model);
|
||||
ServiceViewModel? GetElement(ServiceSearchModel model);
|
||||
ServiceViewModel? Insert(ServiceBindingModel model);
|
||||
ServiceViewModel? Update(ServiceBindingModel model);
|
||||
ServiceViewModel? Delete(ServiceBindingModel model);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,18 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using VetClinicContracts.ViewModels;
|
||||
|
||||
namespace VetClinicDataBaseImplement.Implements
|
||||
{
|
||||
public class VisitsGuidesViewModel
|
||||
{
|
||||
public string MedicineName { get; set; } = string.Empty;
|
||||
public List<VisitViewModel> Visits { get; set; } = new();
|
||||
public List<GuidanceViewModel> Guidances { get; set; } = new();
|
||||
public DateTime DateFrom { get; set; } = DateTime.Now;
|
||||
public DateTime DateTo { get; set; } = DateTime.Now;
|
||||
}
|
||||
}
|
@ -29,44 +29,10 @@ namespace VetClinicDataBaseImplement.Implements
|
||||
.ThenInclude(x => x.Animal).Include(x => x.Services).ThenInclude(x => x.Service)
|
||||
.Where(x => (string.IsNullOrEmpty(model.MedicineName) || x.MedicineName.Contains(model.MedicineName))
|
||||
&& (!model.PharmacistId.HasValue || x.PharmacistId == model.PharmacistId)
|
||||
)
|
||||
&& (!model.ServiceId.HasValue || x.Services.Select(x => x.ServiceId).ToList().Contains(model.ServiceId.Value)))
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
public List<Tuple<MedicineViewModel, List<Tuple<ServiceViewModel, List<GuidanceViewModel>>>>> GetGuidancesInfo(VisitGuidesSearchModel model)
|
||||
{
|
||||
if (model.medicinesIds == null)
|
||||
{
|
||||
return new();
|
||||
}
|
||||
using var context = new VetClinicDatabase();
|
||||
return context.Medicines
|
||||
.Where(medicine => model.medicinesIds.Contains(medicine.Id))
|
||||
.Select(medicine => new Tuple<MedicineViewModel, List<Tuple<ServiceViewModel, List<GuidanceViewModel>>>>(medicine.GetViewModel,
|
||||
context.ServiceMedicines.Include(service => service.Service)
|
||||
.Include(service => service.Medicine).Where(service => medicine.Id == service.MedicineId).
|
||||
Select(service => new Tuple<ServiceViewModel, List<GuidanceViewModel>>(service.Service.GetViewModel,
|
||||
context.Guidances.Include(x => x.Service).Where(x => x.ServiceId == service.ServiceId && x.Date >= model.DateFrom && x.Date <= model.DateTo).
|
||||
Select(x => x.GetViewModel).ToList())).ToList())).ToList();
|
||||
|
||||
}
|
||||
public List<Tuple<MedicineViewModel, List<Tuple<ServiceViewModel, List<VisitViewModel>>>>> GetVisitsInfo(VisitGuidesSearchModel model)
|
||||
{
|
||||
if (model.medicinesIds == null)
|
||||
{
|
||||
return new();
|
||||
}
|
||||
using var context = new VetClinicDatabase();
|
||||
return context.Medicines
|
||||
.Where(medicine => model.medicinesIds.Contains(medicine.Id))
|
||||
.Select(medicine => new Tuple<MedicineViewModel, List<Tuple<ServiceViewModel, List<VisitViewModel>>>>(medicine.GetViewModel,
|
||||
context.ServiceMedicines.Include(service => service.Service)
|
||||
.Include(service => service.Medicine).Where(service => medicine.Id == service.MedicineId).
|
||||
Select(service => new Tuple<ServiceViewModel, List<VisitViewModel>>(service.Service.GetViewModel,
|
||||
context.ServiceVisits.Include(x => x.Visit).Where(x => x.ServiceId == service.ServiceId && x.Visit.DateVisit >= model.DateFrom && x.Visit.DateVisit <= model.DateTo).
|
||||
Select(x => x.Visit.GetViewModel).ToList())).ToList())).ToList();
|
||||
|
||||
}
|
||||
public MedicineViewModel? GetElement(MedicineSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.MedicineName) &&
|
||||
|
@ -32,7 +32,8 @@ namespace VetClinicDataBaseImplement.Implements
|
||||
.Include(x => x.Medicines)
|
||||
.ThenInclude(x => x.Medicine)
|
||||
.Where(x => (string.IsNullOrEmpty(model.ServiceName) || x.ServiceName.Contains(model.ServiceName))
|
||||
&& (!model.PharmacistId.HasValue || x.PharmacistId == model.PharmacistId))
|
||||
&& (!model.PharmacistId.HasValue || x.PharmacistId == model.PharmacistId)
|
||||
&& (!model.MedicineId.HasValue || x.Medicines.Select(x => x.MedicineId).ToList().Contains(model.MedicineId.Value)))
|
||||
.ToList()
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
@ -66,23 +67,6 @@ namespace VetClinicDataBaseImplement.Implements
|
||||
context.SaveChanges();
|
||||
return newService.GetViewModel;
|
||||
}
|
||||
public List<Tuple<ServiceViewModel, List<Tuple<MedicineViewModel, List<AnimalViewModel>>>>> GetReportInfo(ListAnimalsSearchModel model)
|
||||
{
|
||||
if (model.servicesIds == null)
|
||||
{
|
||||
return new();
|
||||
}
|
||||
using var context = new VetClinicDatabase();
|
||||
return context.Services
|
||||
.Where(service => model.servicesIds.Contains(service.Id))
|
||||
.Select(service => new Tuple<ServiceViewModel, List<Tuple<MedicineViewModel, List<AnimalViewModel>>>>(service.GetViewModel,
|
||||
context.ServiceMedicines.Include(medicine => medicine.Medicine)
|
||||
.Include(medicine => medicine.Service).Where(medicine => service.Id == medicine.ServiceId).
|
||||
Select(medicine => new Tuple<MedicineViewModel, List<AnimalViewModel>>(medicine.Medicine.GetViewModel,
|
||||
context.MedicineAnimals.Include(x => x.Animal).Where(x => x.MedicineId == medicine.Medicine.Id).
|
||||
Select(x => x.Animal.GetViewModel).ToList())).ToList())).ToList();
|
||||
|
||||
}
|
||||
public ServiceViewModel? Update(ServiceBindingModel model)
|
||||
{
|
||||
using var context = new VetClinicDatabase();
|
||||
|
@ -25,7 +25,7 @@ namespace VetClinicDataBaseImplement.Implements
|
||||
using var context = new VetClinicDatabase();
|
||||
return context.Vaccinations.Include(x => x.Animal).Where(x => (!model.Id.HasValue || model.Id == x.Id)
|
||||
&& (!model.AnimalId.HasValue || model.AnimalId == x.AnimalId) && (!model.DateFrom.HasValue || model.DateFrom <= x.DateStamp)
|
||||
&& (!model.DateTo.HasValue || model.DateTo >= x.DateStamp) && (!model.AdminId.HasValue || model.AdminId == x.Animal.AdminId))
|
||||
&& (!model.DateTo.HasValue || model.DateTo >= x.DateStamp))
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
@ -1,16 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using VetClinicContracts.ViewModels;
|
||||
|
||||
namespace VetClinicDataBaseImplement.Implements
|
||||
{
|
||||
public class VisitsGuidesViewModel
|
||||
{
|
||||
string MedicineName { get; set; } = string.Empty;
|
||||
List<VisitViewModel> Visits { get; set; } = new();
|
||||
List<GuidanceViewModel> Guidances { get; set; } = new();
|
||||
}
|
||||
}
|
@ -11,7 +11,7 @@ namespace VetClinicDataBaseImplement
|
||||
{
|
||||
if (optionsBuilder.IsConfigured == false)
|
||||
{
|
||||
optionsBuilder.UseSqlServer(@"Data Source=localhost\SQLEXPRESS02;Initial Catalog=VetClinicDatabase;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True");
|
||||
optionsBuilder.UseSqlServer(@"Data Source=localhost\SQLEXPRESS;Initial Catalog=VetClinicDatabase;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True");
|
||||
}
|
||||
base.OnConfiguring(optionsBuilder);
|
||||
}
|
||||
|
@ -21,36 +21,22 @@ namespace VetClinicRestApi.Controllers
|
||||
_logger = logger;
|
||||
_vaccination = vaccination;
|
||||
}
|
||||
[HttpGet]
|
||||
public VaccinationViewModel GetVaccination(int vaccinationId)
|
||||
{
|
||||
try
|
||||
{
|
||||
var elem = _vaccination.ReadElement(new VaccinationSearchModel { Id = vaccinationId });
|
||||
return elem;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка получения прививки по id={Id}", vaccinationId);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public List<VaccinationViewModel>? GetVaccinations(int? adminld)
|
||||
public List<VaccinationViewModel>? GetVaccinations(int? animalId)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!adminld.HasValue)
|
||||
if (!animalId.HasValue)
|
||||
return _vaccination.ReadList(null);
|
||||
return _vaccination.ReadList(new VaccinationSearchModel
|
||||
{
|
||||
AdminId = adminld
|
||||
AnimalId = animalId
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка получения списка прививок пользователя id ={ Id}", adminld);
|
||||
_logger.LogError(ex, "Ошибка получения списка привиовк животного id ={ Id}", animalId);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user