ТрЭш
This commit is contained in:
parent
9f29d4e15e
commit
ac470df39d
@ -0,0 +1,89 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using VetClinicBusinessLogic.OfficePackage;
|
||||
using VetClinicBusinessLogic.OfficePackage.HelperModels;
|
||||
using VetClinicContracts.BindingModels;
|
||||
using VetClinicContracts.BusinessLogicsContracts;
|
||||
using VetClinicContracts.SearchModels;
|
||||
using VetClinicContracts.StoragesContracts;
|
||||
using VetClinicContracts.ViewModels;
|
||||
|
||||
namespace VetClinicBusinessLogic.BusinessLogics
|
||||
{
|
||||
public class ReportLogicPharmacist : IReportLogicPharmacist
|
||||
{
|
||||
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,
|
||||
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)
|
||||
{
|
||||
var medicines = _medicineStorage.GetFilteredList(new MedicineSearchModel { ServiceId = service });
|
||||
Dictionary<int, int> counter = new();
|
||||
foreach (var medicine in medicines)
|
||||
{
|
||||
var animals = _animalStorage.GetFilteredList(new AnimalSearchModel { MedicineId = medicine.Id });
|
||||
foreach (var animal in animals)
|
||||
{
|
||||
if (!counter.ContainsKey(animal.Id))
|
||||
counter.Add(animal.Id, 1);
|
||||
else
|
||||
{
|
||||
counter[animal.Id]++;
|
||||
}
|
||||
}
|
||||
}
|
||||
List<AnimalViewModel> res = new();
|
||||
foreach (var cnt in counter)
|
||||
{
|
||||
if (cnt.Value != medicines.Count)
|
||||
continue;
|
||||
res.Add(_animalStorage.GetElement(new AnimalSearchModel { Id = cnt.Key }));
|
||||
}
|
||||
ans.Add(new ListAnimalsViewModel
|
||||
{
|
||||
ServiceName = _serviceStorage.GetElement(new ServiceSearchModel { Id = service }).ServiceName,
|
||||
Animals = res
|
||||
});
|
||||
}
|
||||
return ans;
|
||||
}
|
||||
|
||||
public void SaveAnimalsToExcelFile(ListAnimalsBindingModel model)
|
||||
{
|
||||
_saveToExcel.CreateReport(new ExcelInfoPharmacist
|
||||
{
|
||||
FileName = model.FileName,
|
||||
Title = "Список животных для услуг",
|
||||
ServicesAnimals = GetServiceAnimals(model.Services)
|
||||
});
|
||||
}
|
||||
|
||||
public void SaveAnimalsToWordFile(ListAnimalsBindingModel model)
|
||||
{
|
||||
_saveToWord.CreateDoc(new WordInfoPharmacist
|
||||
{
|
||||
FileName = model.FileName,
|
||||
Title = "Список животных для услуг",
|
||||
ServicesAnimals = GetServiceAnimals(model.Services)
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace HospitalContracts.BindingModels
|
||||
{
|
||||
public class ListRecipesBindingModel
|
||||
{
|
||||
public string FileName { get; set; } = string.Empty;
|
||||
public List<int> Procedures { get; set; } = new();
|
||||
}
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
using HospitalContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using HospitalContracts.BindingModels;
|
||||
using HospitalContracts.ViewModels;
|
||||
|
||||
namespace HospitalContracts.BusinessLogicsContracts
|
||||
{
|
||||
public interface IReportLogicPharmacist //В процессе
|
||||
{
|
||||
List<ListAnimalsViewModel> GetServiceAnimals(List<int> services);
|
||||
void SaveAnimalsToWordFile(ListRecipesBindingModel model);
|
||||
void SaveAnimalsToExcelFile(ListRecipesBindingModel model);
|
||||
}
|
||||
}
|
14
Hospital/HospitalContracts/ViewModels/ListRecipeViewModel.cs
Normal file
14
Hospital/HospitalContracts/ViewModels/ListRecipeViewModel.cs
Normal file
@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace HospitalContracts.ViewModels
|
||||
{
|
||||
public class ListAnimalsViewModel
|
||||
{
|
||||
public string ProcedureName { get; set; } = string.Empty;
|
||||
public List<RecipeViewModel> Animals { get; set; } = new();
|
||||
}
|
||||
}
|
@ -3,16 +3,16 @@
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>@ViewData["Title"] - HospitalPharmacistApp</title>
|
||||
<title>@ViewData["Title"] - HospitalDoctorApp</title>
|
||||
<link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.min.css" />
|
||||
<link rel="stylesheet" href="~/css/site.css" asp-append-version="true" />
|
||||
<link rel="stylesheet" href="~/HospitalPharmacistApp.styles.css" asp-append-version="true" />
|
||||
<link rel="stylesheet" href="~/HospitalDoctorApp.styles.css" asp-append-version="true" />
|
||||
</head>
|
||||
<body>
|
||||
<header>
|
||||
<nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bg-white border-bottom box-shadow mb-3">
|
||||
<div class="container-fluid">
|
||||
<a class="navbar-brand" asp-area="" asp-controller="Home" asp-action="Index">HospitalPharmacistApp</a>
|
||||
<a class="navbar-brand" asp-area="" asp-controller="Home" asp-action="Index">HospitalDoctorApp</a>
|
||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target=".navbar-collapse" aria-controls="navbarSupportedContent"
|
||||
aria-expanded="false" aria-label="Toggle navigation">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
@ -50,7 +50,7 @@
|
||||
|
||||
<footer class="border-top footer text-muted">
|
||||
<div class="container">
|
||||
© 2024 - HospitalPharmacistApp - <a asp-area="" asp-controller="Home" asp-action="Privacy">Privacy</a>
|
||||
© 2024 - HospitalDoctorApp - <a asp-area="" asp-controller="Home" asp-action="Privacy">Privacy</a>
|
||||
</div>
|
||||
</footer>
|
||||
<script src="~/lib/jquery/dist/jquery.min.js"></script>
|
||||
|
Loading…
Reference in New Issue
Block a user