Нет слов (надеюсь готово)
This commit is contained in:
parent
0dc935797e
commit
993cd30fde
@ -0,0 +1,15 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace HospitalContracts.BindingModels
|
||||
{
|
||||
public class PatientsDescriptionProceduresBindingModel
|
||||
{
|
||||
public string FileName { get; set; } = string.Empty;
|
||||
public List<int> Medicines { get; set; } = new();
|
||||
}
|
||||
}
|
@ -11,6 +11,7 @@ namespace HospitalContracts.SearchModels
|
||||
public int? Id { get; set; }
|
||||
public string? Description { get; set; } = string.Empty;
|
||||
public int? PharmacistId { get; set; }
|
||||
|
||||
public int? ProcedureId { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -13,6 +13,8 @@ namespace HospitalContracts.StoragesContracts
|
||||
{
|
||||
List<MedicineViewModel> GetFullList();
|
||||
List<MedicineViewModel> GetFilteredList(MedicineSearchModel model);
|
||||
List<Tuple<MedicineViewModel, List<Tuple<ProcedureViewModel, List<DescriptionProcedureViewModel>>>>> GetDescriptionProceduresInfo(PatientDescriptionProceduresSearchModel model);
|
||||
List<Tuple<MedicineViewModel, List<Tuple<ProcedureViewModel, List<PatientViewModel>>>>> GetPatientsInfo(PatientDescriptionProceduresSearchModel model);
|
||||
MedicineViewModel? GetElement(MedicineSearchModel model);
|
||||
MedicineViewModel? Insert(MedicineBindingModel model);
|
||||
MedicineViewModel? Update(MedicineBindingModel model);
|
||||
|
@ -35,6 +35,40 @@ namespace HospitalDatabaseImplement.Implements
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
public List<Tuple<MedicineViewModel, List<Tuple<ProcedureViewModel, List<DescriptionProcedureViewModel>>>>> GetDescriptionProceduresInfo(PatientDescriptionProceduresSearchModel model)
|
||||
{
|
||||
if (model.medicinesIds == null)
|
||||
{
|
||||
return new();
|
||||
}
|
||||
using var context = new HospitalDatabase();
|
||||
return context.Medicines
|
||||
.Where(medicine => model.medicinesIds.Contains(medicine.Id))
|
||||
.Select(medicine => new Tuple<MedicineViewModel, List<Tuple<ProcedureViewModel, List<DescriptionProcedureViewModel>>>>(medicine.GetViewModel,
|
||||
context.ProcedureMedicines.Include(service => service.Procedure)
|
||||
.Include(service => service.Medicine).Where(service => medicine.Id == service.MedicineId).
|
||||
Select(service => new Tuple<ProcedureViewModel, List<DescriptionProcedureViewModel>>(service.Procedure.GetViewModel,
|
||||
context.DescriptionProcedures.Include(x => x.Procedures).
|
||||
Select(x => x.GetViewModel).ToList())).ToList())).ToList();
|
||||
|
||||
}
|
||||
public List<Tuple<MedicineViewModel, List<Tuple<ProcedureViewModel, List<PatientViewModel>>>>> GetPatientsInfo(PatientDescriptionProceduresSearchModel model)
|
||||
{
|
||||
if (model.medicinesIds == null)
|
||||
{
|
||||
return new();
|
||||
}
|
||||
using var context = new HospitalDatabase();
|
||||
return context.Medicines
|
||||
.Where(medicine => model.medicinesIds.Contains(medicine.Id))
|
||||
.Select(medicine => new Tuple<MedicineViewModel, List<Tuple<ProcedureViewModel, List<PatientViewModel>>>>(medicine.GetViewModel,
|
||||
context.ProcedureMedicines.Include(service => service.Procedure)
|
||||
.Include(service => service.Medicine).Where(service => medicine.Id == service.MedicineId).
|
||||
Select(service => new Tuple<ProcedureViewModel, List<PatientViewModel>>(service.Procedure.GetViewModel,
|
||||
context.PatientProcedures.Include(x => x.Patient).Where(x => x.ProcedureId == service.ProcedureId ).
|
||||
Select(x => x.Patient.GetViewModel).ToList())).ToList())).ToList();
|
||||
|
||||
}
|
||||
|
||||
public MedicineViewModel? GetElement(MedicineSearchModel model)
|
||||
{
|
||||
|
@ -89,18 +89,18 @@ namespace HospitalDatabaseImplement.Implements
|
||||
using var transaction = context.Database.BeginTransaction();
|
||||
try
|
||||
{
|
||||
var iceCream = context.Procedures.Include(x => x.Pharmacist)
|
||||
var Procedure = context.Procedures.Include(x => x.Pharmacist)
|
||||
.Include(x => x.Medicines).ThenInclude(x => x.Medicine).FirstOrDefault(rec =>
|
||||
rec.Id == model.Id);
|
||||
if (iceCream == null)
|
||||
if (Procedure == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
iceCream.Update(model);
|
||||
Procedure.Update(model);
|
||||
context.SaveChanges();
|
||||
iceCream.UpdateMedicines(context, model);
|
||||
Procedure.UpdateMedicines(context, model);
|
||||
transaction.Commit();
|
||||
return iceCream.GetViewModel;
|
||||
return Procedure.GetViewModel;
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user