Compare commits

...

4 Commits

Author SHA1 Message Date
gg12 darfren
51cc93b256 бебра 2024-05-03 19:25:52 +04:00
c0fe740dc9 Merge branch 'Worker' 2024-05-02 21:50:16 +04:00
gg12 darfren
99ca054c53 Еще правлю 2024-05-02 19:35:33 +04:00
gg12 darfren
98c303acae СДЕЛАЛ СДЕЛАЛ СДЕЛАЛ 2024-05-02 18:22:44 +04:00
14 changed files with 108 additions and 18 deletions

View File

@ -17,15 +17,13 @@ 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;
}

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

@ -13,8 +13,5 @@ namespace VetClinicContracts.SearchModels
public int? AdminId { get; set; }
public string? AnimalName { get; set; }
public string? Family { get; set; }
public int? MedicineId { get; set; }
public int? VisitId { 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

@ -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

@ -16,8 +16,5 @@ namespace VetClinicContracts.SearchModels
public string? DateVisit { get; set; }
public DateTime? DateFrom { get; set; }
public DateTime? DateTo { get; set; }
public int? ServiceId { get; set; }
public int? AnimalId { 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,7 +13,7 @@ namespace VetClinicContracts.StoragesContracts
{
List<ServiceViewModel> GetFullList();
List<ServiceViewModel> GetFilteredList(ServiceSearchModel model);
public List<Tuple<ServiceViewModel, List<Tuple<MedicineViewModel, List<AnimalViewModel>>>>> GetReportInfo(ListAnimalsSearchModel model);
List<Tuple<ServiceViewModel, List<Tuple<MedicineViewModel, List<AnimalViewModel>>>>> GetReportInfo(ListAnimalsSearchModel model);
ServiceViewModel? GetElement(ServiceSearchModel model);
ServiceViewModel? Insert(ServiceBindingModel model);
ServiceViewModel? Update(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();

View File

@ -33,8 +33,7 @@ namespace VetClinicDataBaseImplement.Implements
return context.Visits.Include(x => x.Admin).Include(x => x.Services)
.ThenInclude(x => x.Service).Include(x => x.Animals).ThenInclude(x => x.Animal)
.Where(x => (string.IsNullOrEmpty(model.NameVisit) || x.NameVisit.Contains(model.NameVisit))
&& (!model.AdminId.HasValue || x.AdminId == model.AdminId)
&& (!model.ServiceId.HasValue || x.Services.Select(x => x.ServiceId).ToList().Contains(model.ServiceId.Value)))
&& (!model.AdminId.HasValue || x.AdminId == model.AdminId))
.Select(x => x.GetViewModel)
.ToList();
}
@ -53,7 +52,7 @@ namespace VetClinicDataBaseImplement.Implements
.Include(animal => animal.Visit).Where(animal => visit.Id == animal.VisitId).
Select(animal => new Tuple<AnimalViewModel, List<VaccinationViewModel>>(animal.Animal.GetViewModel,
context.Vaccinations.Include(x => x.Animal).Where(x => x.AnimalId == animal.AnimalId && x.DateStamp >= model.DateFrom && x.DateStamp <= model.DateTo).
Select(x => x.GetViewModel).ToList())).ToList()).ToList();
Select(x => x.GetViewModel).ToList())).ToList())).ToList();
}
public List<Tuple<VisitViewModel, List<Tuple<AnimalViewModel, List<MedicineViewModel>>>>> GetMedicinesInfo(MedicineVaccinationsSearchModel model)

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();
}
}