всякие приколы

This commit is contained in:
antoc0der 2024-05-03 00:39:48 +04:00
parent a1fbf73d7a
commit 34f93c712a
2 changed files with 11 additions and 10 deletions

View File

@ -13,10 +13,11 @@ namespace VeterinaryContracts.StorageContracts
{
List<MedicationViewModel> GetFullList();
List<MedicationViewModel> GetFilteredList(MedicationSearchModel model);
List<Tuple<MedicationViewModel, List<Tuple<DrugViewModel, List<PurchaseViewModel>>>>> GetReportInfo(ListPurchasesSearchModel model);
MedicationViewModel? GetElement(MedicationSearchModel model);
MedicationViewModel? Insert(MedicationBindingModel model);
MedicationViewModel? Update(MedicationBindingModel model);
MedicationViewModel? Delete(MedicationBindingModel model);
List<ReportPurchaseMedicationViewModel> GetReportMedicationPurchasesList(ListPurchasesSearchModel model);
}
}

View File

@ -83,7 +83,7 @@ namespace VeterinaryDatabaseImplement.Implements
return null;
}
public List<Tuple<MedicationViewModel, List<Tuple<DrugViewModel, List<PurchaseViewModel>>>>> GetReportInfo(ListPurchasesSearchModel model)
public List<ReportPurchaseMedicationViewModel> GetReportMedicationPurchasesList(ListPurchasesSearchModel model)
{
if (model.medicationsIds == null)
{
@ -91,14 +91,14 @@ namespace VeterinaryDatabaseImplement.Implements
}
using var context = new VeterinaryDatabase();
return context.Medications
.Where(pet => model.medicationsIds.Contains(pet.Id))
.Select(pet => new Tuple<PetViewModel, List<Tuple<VisitViewModel, List<ServiceViewModel>>>>(pet.GetViewModel,
context.VisitPets.Include(visit => visit.Visit)
.Include(visit => visit.Pet).Where(visit => pet.Id == visit.PetId).
Select(visit => new Tuple<VisitViewModel, List<ServiceViewModel>>(visit.Visit.GetViewModel,
context.Services.Include(x => x.Visits).Where(x => x.MedicineId == visit.Medicine.Id).
Select(x => x.Animal.GetViewModel).ToList())).ToList())).ToList();
.Where(medication => model.medicationsIds == null || model.medicationsIds.Contains(medication.Id))
.Select(medication => new ReportPurchaseMedicationViewModel()
{
MedicationName = medication.MedicationName,
Purchases = context.Purchases.Include(purchase => purchase.Drug).ThenInclude(drug => drug.Medications)
.Where(purchase => purchase.Drug != null && purchase.Drug.Medications.Select(x => x.MedicationId).ToList().Contains(medication.Id))
.Select(purchase => purchase.GetViewModel).ToList()
}).ToList();
}
}
}