Compare commits

...

6 Commits

27 changed files with 362 additions and 108 deletions

View File

@ -6,6 +6,7 @@ using VetClinicContracts.ViewModels;
using VetClinicDataModels.Models;
using System.Text;
using VetClinicContracts.SearchModels;
using System.IO.Pipelines;
namespace VetClinicAdminApp.Controllers
@ -18,7 +19,17 @@ 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)
@ -46,7 +57,7 @@ View(APIAdmin.GetRequest<List<AnimalViewModel>>($"api/animal/getanimallist?admin
return Redirect("~/Home/Enter");
}
return
View(APIAdmin.GetRequest<List<VaccinationViewModel>>($"api/vaccination/getvaccinations?vaccinationId={APIAdmin.Admin.Id}"));
View(APIAdmin.GetRequest<List<VaccinationViewModel>>($"api/vaccination/getvaccinations?adminId={APIAdmin.Admin.Id}"));
}
@ -137,6 +148,7 @@ 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()
@ -145,11 +157,12 @@ 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");
ViewBag.Animals = APIAdmin.GetRequest<List<AnimalViewModel>>($"api/animal/getanimallist?adminid={APIAdmin.Admin.Id}");
return View();
}
@ -192,7 +205,7 @@ View(APIAdmin.GetRequest<List<VaccinationViewModel>>($"api/vaccination/getvaccin
Response.Redirect("IndexAnimals");
}
[HttpPost]
public void CreateVaccination(int animale, string name, double cost,DateTime date)
public void CreateVaccination(int animale, string name, string cost,DateTime date)
{
if (APIAdmin.Admin == null)
{
@ -202,15 +215,35 @@ View(APIAdmin.GetRequest<List<VaccinationViewModel>>($"api/vaccination/getvaccin
{
throw new Exception("Ошибка в введенных данных");
}
if (cost <= 0)
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)
{
throw new Exception("Цена должна быть выше 0");
}
if (date == null)
{
throw new Exception("Выберите дату");
}
APIAdmin.PostRequest("api/vaccination/createvaccination", new VaccinationBindingModel
{
NameVaccination = name,
AnimalId = animale,
CostVaccination = cost,
CostVaccination = Math.Round(_cost, 2),
DateStamp = date
});
Response.Redirect("IndexVaccinations");
@ -292,7 +325,8 @@ View(APIAdmin.GetRequest<List<VaccinationViewModel>>($"api/vaccination/getvaccin
{
return Redirect("~/Home/Enter");
}
ViewBag.Visits = APIAdmin.GetRequest<List<VisitViewModel>>("api/visit/getvisits");
ViewBag.Visits = APIAdmin.GetRequest<List<VisitViewModel>>($"api/visit/getvisits?pharmacistid={APIAdmin.Admin.Id}");
ViewBag.Services = APIAdmin.GetRequest<List<ServiceViewModel>>($"api/service/getservices");
return View();
}
@ -322,6 +356,7 @@ 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();
}
@ -429,6 +464,7 @@ 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();
}

View File

@ -16,7 +16,18 @@
<div class="row">
<div class="col-4">Дата:</div>
<div class="col-8">
<input type="datetime" id="datetime" name="date" />
<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>
</div>
</div>
<div class="row">

View File

@ -20,7 +20,6 @@
<p>
<a asp-action="Update">Редактировать визит</a>
<a asp-action="Delete">Удалить визит</a>
<a asp-action="ServiceVisits">Связать визит и услуги</a>
</p>
<p>
<a asp-action="Create">Создать визит</a>

View File

@ -0,0 +1,59 @@
@{
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>

View File

@ -0,0 +1,30 @@
@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>

View File

@ -1,65 +0,0 @@
@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>
}

View File

@ -22,10 +22,20 @@
<div class="row">
<div class="col-4">Дата:</div>
<div class="col-8">
<input type="datetime" id="datetime" name="date" />
<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>
</div>
</div>
<div class="row">
<div class="col-8"></div>
@ -46,6 +56,10 @@
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")
});
}
});
};

View File

@ -43,7 +43,7 @@
data: { animalId: animal },
success: function (result) {
$('#name').val(result.item1.animalName);
$('#family').val(result.item1.price);
$('#family').val(result.item1.family);
}
});
};

View File

@ -12,6 +12,17 @@
<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">
@ -44,13 +55,20 @@
if (snack) {
$.ajax({
method: "POST",
url: "/Home/GetAnimal",
data: { animal: animal },
url: "/Home/GetVaccination",
data: { vaccinationId: vaccinationId },
success: function (result) {
$("#animal").val(result);
$('#name').val(result.text);
$('#cost').val(result.text);
$('#date').val(result.date);
$(`option[data-name=${result.animalId}]`).attr("selected", "selected")
}
});
};
}
check();
$('#vaccination').on('change', function () {
check();
});
</script>

View File

@ -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" id="@visit.NameVisit">@visit.NameVisit</option>
<option value="@visit.Id" data-name="@visit.NameVisit">@visit.NameVisit</option>
}
</select>
</div>

View File

@ -32,6 +32,12 @@
<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>

View File

@ -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, IAnimalStorage animalStorage,
public ReportLogicPharmacist(IServiceStorage serviceStorage, IMedicineStorage medicineStorage,
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();
foreach(var service in services)
List<Tuple<ServiceViewModel, List<Tuple<MedicineViewModel, List<AnimalViewModel>>>>> response =
_serviceStorage.GetReportInfo(new ListAnimalsSearchModel { servicesIds = services});
foreach (var service in response)
{
var medicines = _medicineStorage.GetFilteredList(new MedicineSearchModel { ServiceId = service });
Dictionary<int, int> counter = new();
foreach(var medicine in medicines)
Dictionary<int, (AnimalViewModel, int)> counter = new();
foreach (var medicine in service.Item2)
{
var animals = _animalStorage.GetFilteredList(new AnimalSearchModel { MedicineId = medicine.Id });
foreach(var animal in animals)
foreach (var animal in medicine.Item2)
{
if (!counter.ContainsKey(animal.Id))
counter.Add(animal.Id, 1);
counter.Add(animal.Id, (animal, 1));
else
{
counter[animal.Id]++;
counter[animal.Id] = (counter[animal.Id].Item1, counter[animal.Id].Item2 + 1);
}
}
}
List<AnimalViewModel> res = new();
foreach(var cnt in counter)
foreach (var cnt in counter)
{
if (cnt.Value != medicines.Count)
if (cnt.Value.Item2 != service.Item2.Count)
continue;
res.Add(_animalStorage.GetElement(new AnimalSearchModel { Id = cnt.Key }));
res.Add(cnt.Value.Item1);
}
ans.Add(new ListAnimalsViewModel
{
ServiceName = _serviceStorage.GetElement(new ServiceSearchModel { Id = service}).ServiceName,
ServiceName = service.Item1.ServiceName,
Animals = res
});
}

View File

@ -0,0 +1,16 @@
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;
}
}

View File

@ -0,0 +1,13 @@
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; }
}
}

View File

@ -11,6 +11,5 @@ 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; }
}
}

View File

@ -11,6 +11,5 @@ 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; }
}
}

View File

@ -9,6 +9,7 @@ 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; }

View File

@ -0,0 +1,15 @@
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; }
}
}

View File

@ -17,5 +17,8 @@ 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);
}
}

View File

@ -13,9 +13,11 @@ 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);
}
}

View File

@ -0,0 +1,18 @@
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;
}
}

View File

@ -29,10 +29,44 @@ 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) &&

View File

@ -32,8 +32,7 @@ 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.MedicineId.HasValue || x.Medicines.Select(x => x.MedicineId).ToList().Contains(model.MedicineId.Value)))
&& (!model.PharmacistId.HasValue || x.PharmacistId == model.PharmacistId))
.ToList()
.Select(x => x.GetViewModel)
.ToList();
@ -67,6 +66,23 @@ 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();

View File

@ -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.DateTo.HasValue || model.DateTo >= x.DateStamp) && (!model.AdminId.HasValue || model.AdminId == x.Animal.AdminId))
.Select(x => x.GetViewModel)
.ToList();
}

View File

@ -0,0 +1,16 @@
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();
}
}

View File

@ -11,7 +11,7 @@ namespace VetClinicDataBaseImplement
{
if (optionsBuilder.IsConfigured == false)
{
optionsBuilder.UseSqlServer(@"Data Source=localhost\SQLEXPRESS;Initial Catalog=VetClinicDatabase;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True");
optionsBuilder.UseSqlServer(@"Data Source=localhost\SQLEXPRESS02;Initial Catalog=VetClinicDatabase;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True");
}
base.OnConfiguring(optionsBuilder);
}

View File

@ -21,22 +21,36 @@ namespace VetClinicRestApi.Controllers
_logger = logger;
_vaccination = vaccination;
}
[HttpGet]
public List<VaccinationViewModel>? GetVaccinations(int? animalId)
public VaccinationViewModel GetVaccination(int vaccinationId)
{
try
{
if (!animalId.HasValue)
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)
{
try
{
if (!adminld.HasValue)
return _vaccination.ReadList(null);
return _vaccination.ReadList(new VaccinationSearchModel
{
AnimalId = animalId
AdminId = adminld
});
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка получения списка привиовк животного id ={ Id}", animalId);
_logger.LogError(ex, "Ошибка получения списка прививок пользователя id ={ Id}", adminld);
throw;
}
}