СДЕЛАЛ СДЕЛАЛ СДЕЛАЛ
This commit is contained in:
parent
eba96483b4
commit
98c303acae
@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace VetClinicContracts.BindingModels
|
||||
{
|
||||
public class VisistsGuidesBindingModel
|
||||
{
|
||||
public string FileName { get; set; } = string.Empty;
|
||||
public List<int> Medicines { get; set; } = new();
|
||||
}
|
||||
}
|
@ -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 VisitServicesSearchModel
|
||||
{
|
||||
public List<int>? medicinesIds { get; set; }
|
||||
}
|
||||
}
|
@ -17,5 +17,8 @@ namespace VetClinicContracts.StoragesContracts
|
||||
MedicineViewModel? Insert(MedicineBindingModel model);
|
||||
MedicineViewModel? Update(MedicineBindingModel model);
|
||||
MedicineViewModel? Delete(MedicineBindingModel model);
|
||||
public List<Tuple<MedicineViewModel, List<Tuple<ServiceViewModel, List<GuidanceViewModel>>>>> GetGuidancesInfo(VisitServicesSearchModel model);
|
||||
public List<Tuple<MedicineViewModel, List<Tuple<ServiceViewModel, List<VisitViewModel>>>>> GetVisitsInfo(VisitServicesSearchModel model);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -33,6 +33,40 @@ namespace VetClinicDataBaseImplement.Implements
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
public List<Tuple<MedicineViewModel, List<Tuple<ServiceViewModel, List<GuidanceViewModel>>>>> GetGuidancesInfo(VisitServicesSearchModel 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).
|
||||
Select(x => x.GetViewModel).ToList())).ToList())).ToList();
|
||||
|
||||
}
|
||||
public List<Tuple<MedicineViewModel, List<Tuple<ServiceViewModel, List<VisitViewModel>>>>> GetVisitsInfo(VisitServicesSearchModel 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).
|
||||
Select(x => x.Visit.GetViewModel).ToList())).ToList())).ToList();
|
||||
|
||||
}
|
||||
public MedicineViewModel? GetElement(MedicineSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.MedicineName) &&
|
||||
|
@ -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; }
|
||||
List<GuidanceViewModel> Guidances { get; set; }
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user